How can I fill a text input with a value? I am trying this:
<input id="curso" maxlength="150" name="curso" size="40" type="text"
value="window.location.href.substring(91))" />
But that does not work.
The fillText() method draws filled text on the canvas. The default color of the text is black. Tip: Use the font property to specify font and font size, and use the fillStyle property to render the text in another color/gradient.
# Use Prefill Form Fields for Your Popup CampaignsCopy a predefined smart tag and paste it into an Input Name field. For example, paste {{email}} into the selected input's name field. This will prefill that input.
<input id="curso" maxlength="150" name="curso" size="40" type="text">
<script>
document.getElementById("curso").value =
document.getElementById("curso").defaultValue = window.location.href.substring(91);
</script>
You can't execute JavaScript from within an arbitrary HTML attribute. Only <script>
elements and event handlers can contain JavaScript, so add a <script>
that sets the value.
You also need to set the defaultValue
property so that any form reset resets the value to the desired value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With