•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,800 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 2,367 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 JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 6791 | Replies: 3 | Solved
![]() |
•
•
Join Date: Oct 2006
Location: Karachi,Pakistan
Posts: 27
Reputation:
Rep Power: 2
Solved Threads: 0
i think u mean to say that drop down form field, i think you are from a software developer, we call that drop down. you will have to use javascript. i am not particularly giving you example for that us cities and all but its a simple example which i had mad quite few times back:
<html>
<head>
<!-- ####################### start copying the HEAD code(DMA) here ####################### -->
<script language="javascript">
<!--//
//new Option("text","value")
//this code changes menus
function nullOptionsDMA(aMenu){
var tot=aMenu.options.length
for (i=0;i<tot;i++)
{
aMenu.options[i]=null
}
aMenu.options.length=0;
}
function MySubjectDMA0(aMenu){
nullOptionsDMA(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("Select a page","none");
options[1]=new Option("1","1.htm");
options[2]=new Option("2","2.htm");
options[3]=new Option("3","3.htm");
options[4]=new Option("4","4.htm");
options[0].selected=true
}
}
function MySubjectDMA1(aMenu){
nullOptionsDMA(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("5","none");
options[1]=new Option("6","6.htm");
options[2]=new Option("7","6.htm");
options[3]=new Option("8","7.htm");
options[4]=new Option("9","8.htm");
options[5]=new Option("10","9.htm");
options[0].selected=true
}
}
function MySubjectDMA2(aMenu){
nullOptionsDMA(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("11","none");
options[1]=new Option("12","12.htm");
options[2]=new Option("13","13.htm");
options[3]=new Option("14","14.htm");
options[0].selected=true
}
}
function MySubjectDMA3(aMenu){
nullOptionsDMA(aMenu)
with (aMenu){
//Rewrites the text and values
options[0]=new Option("15","none");
options[1]=new Option("16","16.htm");
options[2]=new Option("17","17.htm");
options[3]=new Option("18","18.htm");
options[0].selected=true
}
}
/* ####################### goDM() ####################### */
function goDMA(aMenu){
if (aMenu.options.value!="none")
{
location=aMenu.options[aMenu.selectedIndex].value
}
}
/* ####################### setUp ####################### */
function setUpDMA(){
with (document.formDoubleMenuDMA) {
if (menuSubjectsDMA.selectedIndex==0){
menuSubjectsDMA.options[0].selected=true
menuFilesDMA.options[0].selected=true
}
if (menuSubjectsDMA.selectedIndex==1)
MySubjectDMA0(menuFilesDMA)
if (menuSubjectsDMA.selectedIndex==2)
MySubjectDMA1(menuFilesDMA)
if (menuSubjectsDMA.selectedIndex==3)
MySubjectDMA2(menuFilesDMA)
if (menuSubjectsDMA.selectedIndex==4)
MySubjectDMA3(menuFilesDMA)
}
}
/* ####################### changeFiles ####################### */
function changeFilesDMA(){
aMenu=document.formDoubleMenuDMA.menuSubjectsDMA
aMenu2=document.formDoubleMenuDMA.menuFilesDMA
with (aMenu){
switch (selectedIndex) {
case 0:
aMenu2.options.length=0;
aMenu2.options[0]=
new Option("Pages appear here","none")
aMenu2.options[0].selected=true;
history.go(0)
break
case 1:
MySubjectDMA0(aMenu2)
aMenu2.options[0].text="1-4"
break
case 2:
MySubjectDMA1(aMenu2)
aMenu2.options[0].text="5-10"
break
case 3:
MySubjectDMA2(aMenu2)
aMenu2.options[0].text="11-14"
break
case 4:
MySubjectDMA3(aMenu2)
aMenu2.options[0].text="15-18"
break
}
}
}
//-->
</script>
<!-- ####################### end copying code (DMA) from the HEAD ####################### -->
</head>
<!-- ####################### don't forget to copy the body code! ####################### -->
<body onLoad="setUpDMA()">
<!-- ####################### copy the code below to where you want the menu to appear ####################### -->
<form name="formDoubleMenuDMA" >
<p><font size="2">Select a subject and then a page to go!</FONT>:<br>
<!-- This menu holds the subjects-->
<select name="menuSubjectsDMA" onChange="changeFilesDMA()">
<option value="none" >Select a subject
<option value="">1-4
<option value="">5-10
<option value="">11-14
<option value="">15-18
</select>
<!-- this menu holds the files to go-->
<select name="menuFilesDMA" onChange="goDMA(this)" style="width:300">
<option value="none"> Pages appear here
</select>
<p>
</form>
<!-- ####################### stop copying the menu code (DMA) here ####################### -->
</body>
</html>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Paasing the values of Combo Box (PHP)
- combo box (PHP)
- Want to use radio button or menu bar instead of combo box (Java)
- combo box (ASP)
- How do I limit text char in Combo box? (VB.NET)
- combo box help (VB.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Javascript Help
- Next Thread: Unsure how to handle advance date calculations



Linear Mode