How do you put a javascript variable into the value=""
of an <input>
box on a <form>
This must be easy but I do not know.
How do you put a javascript variable into the value=""
of an <input>
box on a <form>
This must be easy but I do not know.
That's not hard. Have a look at the example below:
HTML:
<input id="id_of_your_element">
Javascript:
var yourvariable = "Hello world!";
document.getElementById("id_of_your_element").value = yourvariable;
Value="<script type="text/javascript">document.write(yourVariableName);</script>"
You can do just:
document.getElementById('inputId').value = yourVariable;
You can also use the jQuery library, it will:
$('#inputId').val(yourVariable);