Reputation: 713
I have the following fields:
First Name: <input type="text" id="tFName" name="tFName" maxlength="50" />
Last Name: <input type="text" id="tLName" name="tLName" maxlength="50" />
I want to use javaScript specifically dojo to update the value of the following hidden input fields:
<input type="hidden" name="tFName" value=""/>
<input type="hidden" name="tLName" value=""/>
what are some ways in Javascript and Dojo to accomplish this?
Upvotes: 2
Views: 9735
Reputation: 883
If we modify the html some (setting an ID on the hidden ones) we can:
First Name: <input type="text" id="tFName" name="tFName" maxlength="50" />
<input type="hidden" id="hiddenFName" name="tFName" value=""/>
var fName = dijit.byId("tFName");
var hFName = dijit.byId("hiddenFName");
hFName.attr("value", fName.attr("value"));
Upvotes: 2
Reputation: 327
Try this: document.getElementsByName("tFName")[0].value ="abc"; document.getElementsByName("tLName")[0].value ="def";
Upvotes: 1
Reputation: 27067
In plain Javascript, you can just set the .value
property:
document.<form name>.tFName.value = <whatever>
document.<form name>.tLName.value = <whatever>
Upvotes: 3