R
reneeccwest
Different user input boxes are automatically populated based on a
value of the dropdown box.
Can anyone help me on that?
value of the dropdown box.
Can anyone help me on that?
reneeccwest said:Different user input boxes are automatically populated based on a
value of the dropdown box.
Can anyone help me on that?
Grant Wagner said:reneeccwest said: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 <[email protected]>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_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-developer/upgrade_2.html
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.