2

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?

4 Answers 4

5
dojo.query('#tFName').val('Joe');

See the val() docs.

Sign up to request clarification or add additional context in comments.

1 Comment

Just remember to add dojo.require("dojo.NodeList-manipulate"); or this will not work.
3

In plain Javascript, you can just set the .value property:

document.<form name>.tFName.value = <whatever>
document.<form name>.tLName.value = <whatever>

Comments

2

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"));

1 Comment

If some of these is a <select>, this won't work. val() is much better.
1

Try this: document.getElementsByName("tFName")[0].value ="abc"; document.getElementsByName("tLName")[0].value ="def";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.