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 <>
* 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