Jump to content

linked listboxes, or how I can call them?


hugl3

Recommended Posts

Hello everyone.

I was reading this forum for a quit time. But now I registered, because came to the question - I can't solve myself.

Maybe someone here could be of any help.

 

Lets say I have a listbox -

<select size=1 name="listweare">

<OPTION selected value="1">Female</OPTION>

<OPTION value="2">Male</OPTION>

</select>

 

 

What I need to do, is:

 

If the Female is selected in listbox; then show one more listbox to the right - Blonde/Brunette , the code woule be like:

<select size=1 name="hairsyle">

<OPTION selected value="1">Blonde</OPTION>

<OPTION value="2">Brunette</OPTION>

</select>

 

If I switch to Male, this listbox is beign hidden - is it possible to be done ?

 

Thank you!

 

Link to comment
https://forums.phpfreaks.com/topic/108341-linked-listboxes-or-how-i-can-call-them/
Share on other sites

heres the javascript way. This is just the general idea of how its done using a hidden DIV

 

<form name='form1'>

<select size=1 name="listweare" onchange='javascript:checkit(this.form)'>

<OPTION selected value="1">Male</OPTION>

<OPTION value="2">Female</OPTION>

</select>

</form>

<div id='list2' style="visibility: hidden">

<form name='form2'>

<select size=1 name="hairsyle">

<OPTION selected value="1">Blonde</OPTION>

<OPTION value="2">Brunette</OPTION>

</select>

</form>

</div>

<script>

 

function checkit(f){

var box = f.listweare;

var number = box.options[box.selectedIndex].value;

if(number == 2){

el = document.getElementById('list2')

el.style.visibility = 'visible';

}

else{

el = document.getElementById('list2')

el.style.visibility = 'hidden';

}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.