Place JavaScript data in an Input field [duplicate]
Solution 1:
Use the value attribute:
document.getElementById("prdtotal").value = "1.00";
document.getElementById() returns the actual DOM object (a handle/reference to the <input>
element).
Also note your missing double quote before the closing parenthesis.
I would suggest you to take a look at the Mozilla Developer Network (MDN):
HTMLElement: a reference of all attributes a (general) HTML element can have.
HTMLInputElement: a reference of all special attributes an input element (e.g.
<textarea>
,<input>
) can have.
Solution 2:
You've found the element using getElementById
but you've not specified its the value
property you want to set.
document.getElementById("prdtotal").value="1.00"
And a live example: http://jsfiddle.net/hevwt/