...

View Full Version : ComboBox(Quadrouple)...showing values



gingerGamgee
01-07-2004, 12:12 AM
This is my first post!

I modified the quadrouple combobox in one of the previous threads, but I would like a window.alert to pop up and show me my selections at the end. I can't figure out which var holds the value of the combobox (if any). example:

<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option selected>---Select Base Commodity-------------</option>
<option value="S">Steel</option>
<option value="P">Parishable</option>
<option value="G">Glass</option> etc.....

<select name="example1" size="1" onChange="redirect1(this.options.selectedIndex)">
<option selected>---Select Group-------------</option>
<option value="F">Flat</option>
<option value="B">Bar</option>
<option value="T">Tube</option>etc......


If I select "STEEL" from the first combo box, I want the window.alert to read "T", if "Tube" is my second selection, I want the window.alert to read "S T". Get it? Thanks for your help!!

Kor
01-07-2004, 01:55 PM
d = document.forms[0];
alert(d.example.value + d.example1.value);

Kor
01-07-2004, 02:02 PM
...and...

<option selected value="">
or
<option selected value=" - ">

Kor
01-07-2004, 02:15 PM
or, more comprehensive (but only for browsers which support this DHTML method - IE5+, NS6+ and compatible) u may use:

d = document.getElementsByTagName('select');
dd="";
for(i=0;i<d.length;i++){
dd = dd+d[i].value;
}
alert(dd);

gingerGamgee
01-07-2004, 03:35 PM
That worked great! Thanks everyone!!

Kor
01-07-2004, 04:54 PM
Thanks everyone!!


everyone (all 3 of us :) ) wish you a well coding... And good luck!

I hope you have found here a good place for solving your present/future script problems.

gingerGamgee
01-07-2004, 07:33 PM
What do I do to change the output to a text box instead of an alert?

Kor
01-08-2004, 09:36 AM
....

d = document.getElementsByTagName('select');
dd="";
for(i=0;i<d.length;i++){
dd = dd+d[i].value;
}
document.forms[0].alerthere.value = dd;

..

<body>
...
...
<input name="alerthere" type="text" readonly="true">

gingerGamgee
01-09-2004, 01:48 AM
Thanks Kor. That worked perfectly. I have another post called "Sooo Slow" can you look at it??? This script is slow at loading. Do you see any reason for this?? Every thing is working perfectly and I am ready to use it! Thanks! (I love this place!)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum