Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Different user input boxes are automatically populated based on a value of the dropdown box.

Reply
Thread Tools

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

 
 
reneeccwest
Guest
Posts: n/a
 
      07-03-2003
Different user input boxes are automatically populated based on a
value of the dropdown box.

Can anyone help me on that?
 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      07-10-2003
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


 
Reply With Quote
 
 
 
 
reneeccwest
Guest
Posts: n/a
 
      07-11-2003
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" <> wrote in message
news:...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Space between input boxes and selection boxes is not the same in Internet Explorer Stefan Mueller HTML 5 06-16-2009 02:06 PM
Change value of one variable based on user input of another value TeknoShock Javascript 1 12-01-2006 05:06 PM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
populate a dg column based upon the value populated to another row in the datagrid Mike P ASP .Net 1 01-13-2006 11:43 AM
Pass input Array value to function to calc different input value Susan Cranford Javascript 2 07-05-2005 02:53 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57