By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Different user input boxes are automatically populated based on a value of the dropdown box.

P: n/a
Different user input boxes are automatically populated based on a
value of the dropdown box.

Can anyone help me on that?
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
reneeccwest wrote:
Different user input boxes are automatically populated based on a
value of the dropdown box.

Can anyone help me on that?


<form name="myForm">
<input type="text" name="inputOne">
<input type="text" name="anotherInput">
<select name="mySelect" onchange="setInputs(this);">
<option value="None">Choose</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
</form>
<script type="text/javascript">
var inputValues =
[
{
inputOne:'',
anotherInput:''
},
{
inputOne:'value for One',
anotherInput:'another value for One'
},
{
inputOne:'Two was picked',
anotherInput:'Tooooo'
}
];

function setInputs(selObj) {
var f = selObj.form;

var selectedItem = selObj.selectedIndex;

var inputs = inputValues[selectedItem];

for (var input in inputs) {
f.elements[input].value = inputs[input];
}
}
</script>

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

P: n/a
thank you for your help!
but i meant...
Depends on the value of the combo box, text input boxes will be dynamic.
for example,
there are 5 text input boxes (let's name them as "inputOne", "inputTwo",
"inputThree", "inputFour", and "inputFive") and if the value of combox is
selected as "One",
then the first text input box ("inputOne") and the third input box
("inputThird")will be appeared, but rest of them will be disappeared.

if the value of combox is selected as "two",
then the second text input box ("inputsecond"), the fourth text input box
("inputFourth") and the five input box ("inputThird")will be appeared, but
rest of them will be disappeared.
"Grant Wagner" <gw*****@agricoreunited.com> wrote in message
news:3F***************@agricoreunited.com...
reneeccwest wrote:
Different user input boxes are automatically populated based on a
value of the dropdown box.

Can anyone help me on that?
<form name="myForm">
<input type="text" name="inputOne">
<input type="text" name="anotherInput">
<select name="mySelect" onchange="setInputs(this);">
<option value="None">Choose</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
</form>
<script type="text/javascript">
var inputValues =
[
{
inputOne:'',
anotherInput:''
},
{
inputOne:'value for One',
anotherInput:'another value for One'
},
{
inputOne:'Two was picked',
anotherInput:'Tooooo'
}
];

function setInputs(selObj) {
var f = selObj.form;

var selectedItem = selObj.selectedIndex;

var inputs = inputValues[selectedItem];

for (var input in inputs) {
f.elements[input].value = inputs[input];
}
}
</script>

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*

http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.