Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Three Linked List Boxes - HOWTO? 1

Status
Not open for further replies.

Deadline

Programmer
Feb 28, 2001
367
US
Hello,
Do we have an FAQ or another thread that deals with three linked list boxes ? I saw an article at But I wish it were more complete. Or is it my lack of understanding..

Could you please assist me by giving a code for the same or by directing me somewhere that code exists ? The only condition is that it should not submit each time the listbox's selection changes.

Keywords
List Box ListBox DropDown DropDownBox Drop Down Three Triple Linked Double Multiple populate Thank you...
RR
 
I have had a look at that article, do you mean you want the contents of the other two select boxes to change onChange of the first? Or something similar?

Well, like they say, use arrays because we want to loop thru them to populate. There are many ways to do this, here is the idea. I will illustrate with an example using just 2 select boxes, one is called vehicles, the other is called display.

<FORM>
Select a type:
<select name=&quot;vehicles&quot; onChange=&quot;setContent(this,display)&quot;>
<option><<select>></option>
<option value=CARS>Cars</option>
<option value=TRUCKS>Trucks</option>
</select>

<select name=&quot;display&quot; >
<option>no type selected -select from other box to display.</option>
</select>
</FORM>


Here is the function that is called: It takes two objects as args - both select boxes.
var CARS = new Array(&quot;Ford&quot;,&quot;Holden&quot;,&quot;Volkswagen&quot;);
var TRUCKS = new Array(&quot;Western Star&quot;,&quot;Mack&quot;,&quot;Kenworth&quot;)

function setContent(selectBox,content){
// Must evalate the string to convert to the variable holding the array.
// So the source for the content select box becomes one of the arrays above,
// Not a string.

var sourceArray = eval(selectBox[selectBox.selectedIndex].value);
// We need to set the content select box big enough to take the new options,
// but we do not have to explicitly create new options

content.options.length = sourceArray.length;
// Fill the content select box with the value from the appropriate array.

for(var j=0;j<sourceArray.length;j++){
content.options[j].value = sourceArray[j];
content.options[j].text = sourceArray[j];
}
//done ;-)

}



So then you would just extend this to change two other selects instead of one, using some logic.
I hope this clears it up a bit!
Bj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top