i have page contain two combo box


USA UK GERMANY

i want that if i select usa then 2nd combo box will shows only cities of usa plz provide me help

There is no such thing as a combobox in HTML. Are you posting in the correct forum?

Do you mean a dropdown form field?

Member Avatar for GreenDay2001

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>

i also face the same problem...i want to do 2 level dorpdown form field..means that i can choose the country for 2 times...
example chioce 1 usa then it will appear city in usa
then i can choose in the 2nd level country eg germany,then it will appear city for germany...my coding only work for the 1st country,when i go to the second country,it will at the 1st country 2nd dropdwon box also...how can i solve my problem? any ideas? maybe i can put my coding so u can see my error...

http://www.4shared.com/file/108259418/18988a6a/addrecord.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.