Hi...everyone
Below i have attached my code. This code is working.....but i want some modification in that code such that when i select 'vegetable' or 'fruits', it should give list of that selected one in second list, BUT THAT list should be stored in mysql database.
In the below program , i have hard-coded that second list, but i want second list to be dynamic from database.
Please, help me out.
Thank you for your help in advance
Code:<HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!--Begin JavaScript function setList(f) { secondlist=eval("'"+f.elements['list1'].options[f.elements['list1'].selectedIndex].text+"'"); f.elements['list2'].options.length=0; size=eval("lists['"+secondlist+"'].length"); for(i=0;i<size;i++) { newval=eval("lists['"+secondlist+"'][i]"); f.elements['list2'].options[i]=new Option(newval); }; f.elements['list2'].selectedIndex=0; }; lists=new Array(); lists['Fruit'] = new Array(); lists['Fruit'][0]="apple"; lists['Fruit'][1]="banana"; lists['Fruit'][2]="cantelope"; lists['Fruit'][3]="grape"; lists['Fruit'][4]="honeydew"; lists['Fruit'][5]="kiwi"; lists['Fruit'][6]="lemon"; lists['Fruit'][7]="lime"; lists['Fruit'][8]="mango"; lists['Vegetables'] = new Array(); lists['Vegetables'][0]="carrot"; lists['Vegetables'][1]="celery"; lists['Vegetables'][2]="onion"; lists['Vegetables'][3]="potato"; lists['Vegetables'][4]="squash"; lists['Vegetables'][5]="tomato"; //End JavaScript--> </SCRIPT> <BODY BGCOLOR=WHITE onLoad="setList(document.listsform)"> <FORM NAME="listsform"> <SELECT NAME="list1" onChange="setList(form)"> <OPTION>Fruit</OPTION> <OPTION>Vegetables</OPTION> </SELECT> <SELECT NAME="list2"> <OPTION> </OPTION> <OPTION></OPTION> <OPTION></OPTION> <OPTION></OPTION> <OPTION></OPTION> <OPTION></OPTION> <OPTION></OPTION> <OPTION></OPTION> <OPTION></OPTION> </SELECT> </FORM> </BODY></HTML>





Reply With Quote
Bookmarks