Scripty The Kid
08-06-2003, 04:41 PM
I think it was called dynamic or something... Anyway, I've been searching around the net, looking for something to point me in the right direction to no avail. So I've come here to get my question answered.
Anyway the thing I have, is two lists. The second one changes depending on what the first one is. What I want to do is create a submit button for the form that will send you to a different page for the different things selected.
This is the script. What can I do to it to add a button like the one I want?
<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['FirstField'] = new Array();
lists['FirstField'][0]="1";
lists['SecondField'] = new Array();
lists['SecondField'][0]="1";
lists['SecondField'][1]="2";
lists['SecondField'][2]="3";
lists['SecondField'][3]="4";
lists['SecondField'][4]="5";
lists['ThirdField'] = new Array();
lists['ThirdField'][0]="1";
lists['ThirdField'][1]="2";
lists['ThirdField'][2]="3";
lists['ThirdField'][3]="4";
lists['ThirdField'][4]="5";
lists['FourthField'] = new Array();
lists['FourthField'][0]="?";
lists['FourthField'][1]="?";
lists['FourthField'][2]="?";
lists['FourthField'][3]="?";
lists['FourthField'][4]="?";
//End JavaScript-->
</SCRIPT>
<BODY BGCOLOR=WHITE onLoad="setList(document.listsform)">
<FORM NAME="listsform">
<SELECT NAME="list1" onChange="setList(form)">
<OPTION>FirstField</OPTION>
<OPTION>SecondField</OPTION>
<OPTION>ThirdField</OPTION>
<OPTION>FourthField</OPTION>
</SELECT>
<SELECT NAME="list2">
<OPTION> </OPTION>
<OPTION></OPTION>
<OPTION></OPTION>
<OPTION></OPTION>
<OPTION></OPTION>
</SELECT>
</FORM>
</BODY></HTML>
Anyway the thing I have, is two lists. The second one changes depending on what the first one is. What I want to do is create a submit button for the form that will send you to a different page for the different things selected.
This is the script. What can I do to it to add a button like the one I want?
<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['FirstField'] = new Array();
lists['FirstField'][0]="1";
lists['SecondField'] = new Array();
lists['SecondField'][0]="1";
lists['SecondField'][1]="2";
lists['SecondField'][2]="3";
lists['SecondField'][3]="4";
lists['SecondField'][4]="5";
lists['ThirdField'] = new Array();
lists['ThirdField'][0]="1";
lists['ThirdField'][1]="2";
lists['ThirdField'][2]="3";
lists['ThirdField'][3]="4";
lists['ThirdField'][4]="5";
lists['FourthField'] = new Array();
lists['FourthField'][0]="?";
lists['FourthField'][1]="?";
lists['FourthField'][2]="?";
lists['FourthField'][3]="?";
lists['FourthField'][4]="?";
//End JavaScript-->
</SCRIPT>
<BODY BGCOLOR=WHITE onLoad="setList(document.listsform)">
<FORM NAME="listsform">
<SELECT NAME="list1" onChange="setList(form)">
<OPTION>FirstField</OPTION>
<OPTION>SecondField</OPTION>
<OPTION>ThirdField</OPTION>
<OPTION>FourthField</OPTION>
</SELECT>
<SELECT NAME="list2">
<OPTION> </OPTION>
<OPTION></OPTION>
<OPTION></OPTION>
<OPTION></OPTION>
<OPTION></OPTION>
</SELECT>
</FORM>
</BODY></HTML>