Jump to content

Recommended Posts

Hello!

 

I have this code that creates dependent combo box

 

How can I add: Select option" before the user selects option 2a, 2b or 2c

"select option" should have no value

 

Thank you,

 

<html>
<head>
<title>Dependent Combo Boxes</title>
</head>
<body>
<script type='text/javascript'>
function update(a)
{
if(a==1)
{
document.getElementById("destination").innerHTML="<select name='combo2'><option>option 1 a</option><option>option 1b</option><option>option 1c</option></select>";
}
if(a==2)
{
document.getElementById("destination").innerHTML="<select name='combo2'><option>option 2 a</option><option>option 2b</option><option>option 2c</option></select>";
}
if(a==3)
{
document.getElementById("destination").innerHTML="<select name='combo2'><option>option 3 a</option><option>option 3b</option><option>option 3c</option></select>";
}
}
</script>
<form name='form1'>
<table>
<tr><td><select name='combo1'  onchange='update(this.value)'>
<option value='1'>option 1</option>
<option value='2'>option 2</option>
<option value='3'>option 3</option>
</select>
</td></tr>
<tr><td>
<span id='destination'>
<select name='combo2' disabled='disabled' >
<option>Select combo 1 first</option>
</select>
</span>
</td></tr>

</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/223206-combo-box/
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.