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
Share on other sites

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.