Jump to content

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';

}

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.