•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 425,998 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,672 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 3596 | Replies: 2
![]() |
•
•
Join Date: Jul 2006
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi there,
i have two drop down menus.
what i want to do is when the user chooses an option from the first box, the second box returns to the default (selected) option on change.
Any thoughts are very welcome.
Thanks a lot.
http://www.webdeveloper.com/forum/im...ttons/edit.gif
i have two drop down menus.
what i want to do is when the user chooses an option from the first box, the second box returns to the default (selected) option on change.
Any thoughts are very welcome.
Thanks a lot.
http://www.webdeveloper.com/forum/im...ttons/edit.gif
•
•
Join Date: Apr 2006
Posts: 27
Reputation:
Rep Power: 3
Solved Threads: 1
check out this ways:
call a function onchange of the first combo
where you will have to set the value of the second combo to the default value.
Say if the default value of the second combo is "default_value"
and the name of the function called on change of the first combo is fnOnChangeFirstCombo and the name of the second combo is SecCombo, then use the following code:
[code]
function fnOnChangeFirstCombo()
{
document.frmName.SecCombo.value="default_value";
}
[code]
call a function onchange of the first combo
where you will have to set the value of the second combo to the default value.
Say if the default value of the second combo is "default_value"
and the name of the function called on change of the first combo is fnOnChangeFirstCombo and the name of the second combo is SecCombo, then use the following code:
[code]
function fnOnChangeFirstCombo()
{
document.frmName.SecCombo.value="default_value";
}
[code]
•
•
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,165
Reputation:
Rep Power: 7
Solved Threads: 59
document.frmName.SecCombo.value="default_value";
var combo = document.getElementById("combo2");<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Combo change</title>
<script type="text/javascript">
function combo2_OnChange()
{
var combo = document.getElementById("combo2");
combo.value = "0";
}
</script>
<style type="text/css">
body
{
font-family: verdana;
}
#fieldset1
{
padding: 15px; text-align: center; width: 150px;
}
#combo1
{
font-weight: bold;
color: red;
}
#combo2
{
color: green;
}
</style>
</head>
<body>
<fieldset id="fieldset1">
<legend>Choose options</legend>
<br />
<select id="combo1" onchange="combo2_OnChange();">
<option selected="selected" value="0">Option 1</option>
<option value="1">Option 2</option>
</select>
<hr />
<select id="combo2">
<option selected="selected" value="0">Default</option>
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
</select>
</fieldset>
</body>
</html>
Last edited by hollystyles : Aug 17th, 2006 at 3:36 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Serial Number in Data Reports (Visual Basic 4 / 5 / 6)
- Msn and Hotmail Problems (Web Browsers)
- Overclocking 2600+.. help? (Motherboards, CPUs and RAM)
- PLEASE HELP: Windows XP Major problem (Windows NT / 2000 / XP / 2003)
- Time out web pages w/text or drop boxes (Networking Hardware Configuration)
- reset xp (Web Browsers)
Other Threads in the HTML and CSS Forum
- Previous Thread: CSS For Table
- Next Thread: How to set html page size attributes



Linear Mode