Jump to content

Dynamic combobox problem


robert_gsfame

Recommended Posts

I have 3 combobox, 1 combobox has been set first but the other 2nd combobox will depend on the 1st while the 3rd will depend on the 2nd combobox

here is the javascript code:

 

function showcity()

{

if (document.form1.country.value == "USA"){document.getElementById('mycity').innerHTML = "<select name='city' onchange='showaddress()'><option value='nocity' id='nocity'>Please choose city</option><option value='LA' id='LA'>Los Angeles</option>"}

if (document.form1.country.value == "none"){document.getElementById('mycity').innerHTML = ""}

if (document.form1.country.value == "none"){document.getElementById('myaddress').innerHTML = ""}

 

 

function showaddress()

{

if (document.getElementById("LA")){document.getElementById('myaddress').innerHTML = "<select name='address'><option value="noaddress">Please choose address</option><option value='rose'>Rose street</option></select>"}

if(document.getElementById("nocity")){document.getElementById('myaddress').innerHTML = ""}

}

 

html code:

<form name="form1">

<select name="country" onchange="showcity()">

<option value="none">Please choose at least one</option>

<option value="USA">USA</option>

 

<div id="mycity"></div>

<div id="myaddress"></div>

</form>

 

The problem is when i choose "nocity", the 3rd combobox should disappear but it is not....may be there is something missing with the bold one??

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/196126-dynamic-combobox-problem/
Share on other sites

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.