PDA

View Full Version : 'go' button location change



MonteChristo
02-14-2008, 06:43 PM
i am rather new to javascript. what i am trying to create are three dropdown menu fields - Region Select, Country Select and Language Select, followed by a 'Go' submit button. i have it working to the point where each option is greyed out until you make a selection from the previous dropdown. what i cant figure out is how to make the 'go' button load various pages depending on the previous dropdown choices. (for example if the user selects north america and canada and english, then when the go button is hit, that particular html page would load up.

i have attached my .html and my .js files if anyone is interested! thanks.

MonteChristo
02-14-2008, 11:01 PM
anybody have any ideas? my html file loads in my external .js file. the javascript is as follows:



function fillCategory(){
// this function is used to fill the category list on load
addOption(document.drop_list.Category, "NAmerica", "North America", "");
addOption(document.drop_list.Category, "LAmerica", "Latin America & Caribbean", "");
addOption(document.drop_list.Category, "Africa", "Africa", "");
addOption(document.drop_list.Category, "Europe", "Europe & Middle East", "");
addOption(document.drop_list.Category, "Asia", "Asia Pacific", "");
}

function SelectSubCat(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat);
addOption(document.drop_list.SubCat, "", "COUNTRY SELECT", "");

if(document.drop_list.Category.value == 'NAmerica'){
addOption(document.drop_list.SubCat,"USA", "United States");
addOption(document.drop_list.SubCat,"CAN", "Canada");
}
if(document.drop_list.Category.value == 'LAmerica'){
addOption(document.drop_list.SubCat,"MEX", "Mexico");
}
if(document.drop_list.Category.value == 'Africa'){
addOption(document.drop_list.SubCat,"SAF", "South Africa");
}
if(document.drop_list.Category.value == 'Europe'){
addOption(document.drop_list.SubCat,"UK", "United Kingdom");
addOption(document.drop_list.SubCat,"IRE", "Ireland");
addOption(document.drop_list.SubCat,"SPA", "Spain/Portugal");
addOption(document.drop_list.SubCat,"FRA", "France");
addOption(document.drop_list.SubCat,"GER", "Germany");
addOption(document.drop_list.SubCat,"ITA", "Italy");
addOption(document.drop_list.SubCat,"POL", "Poland", "");
}
if(document.drop_list.Category.value == 'Asia'){
addOption(document.drop_list.SubCat,"IND", "India");
addOption(document.drop_list.SubCat,"JAP", "Japan");
addOption(document.drop_list.SubCat,"AUS", "Australia & New Zealand");
addOption(document.drop_list.SubCat,"SK", "South Korea");
addOption(document.drop_list.SubCat,"CHI", "China");
addOption(document.drop_list.SubCat,"HK", "Hong Kong & Southeast Asia");
addOption(document.drop_list.SubCat,"TAI", "Taiwan");
addOption(document.drop_list.SubCat,"MAL", "Malaysia");
}

}

function SelectSubCat2(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat2);
addOption(document.drop_list.SubCat2, "", "LANGUAGE SELECT", "");

if(document.drop_list.SubCat.value == 'USA'){
addOption(document.drop_list.SubCat2,"English", "English");
}
if(document.drop_list.SubCat.value == 'CAN'){
addOption(document.drop_list.SubCat2,"Cricket", "English");
addOption(document.drop_list.SubCat2,"Cricket", "French");
}
if(document.drop_list.SubCat.value == 'MEX'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Spanish");
}
if(document.drop_list.SubCat.value == 'SAF'){
addOption(document.drop_list.SubCat2,"Cricket", "English");
}
if(document.drop_list.SubCat.value == 'UK'){
addOption(document.drop_list.SubCat2,"PHP", "English");
}
if(document.drop_list.SubCat.value == 'IRE'){
addOption(document.drop_list.SubCat2,"PHP", "English");
}
if(document.drop_list.SubCat.value == 'SPA'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Spanish");
}
if(document.drop_list.SubCat.value == 'FRA'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "French");
}
if(document.drop_list.SubCat.value == 'GER'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "German");
}
if(document.drop_list.SubCat.value == 'ITA'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Italian");
}
if(document.drop_list.SubCat.value == 'POL'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Polish");
}
if(document.drop_list.SubCat.value == 'IND'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Sanskrit");
}
if(document.drop_list.SubCat.value == 'JAP'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Japanese");
}
if(document.drop_list.SubCat.value == 'AUS'){
addOption(document.drop_list.SubCat2,"PHP", "English");
}
if(document.drop_list.SubCat.value == 'SK'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Korean");
}
if(document.drop_list.SubCat.value == 'CHI'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Mandarin");
}
if(document.drop_list.SubCat.value == 'HK'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Cantonese");
}
if(document.drop_list.SubCat.value == 'TAI'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Mandarin");
}
if(document.drop_list.SubCat.value == 'MAL'){
addOption(document.drop_list.SubCat2,"PHP", "English");
addOption(document.drop_list.SubCat2,"PHP", "Malaysian");
}

}

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
//selectbox.options.remove(i);
selectbox.remove(i);
}
}


function addOption(selectbox, value, text )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;

selectbox.options.add(optn);
}


function checkifemptyREGION(){
if (document.drop_list.Category.value=='')
document.drop_list.SubCat.disabled=true
else
document.drop_list.SubCat.disabled=false
}
if (document.all || document.getElementById)
setInterval("checkifemptyREGION()",100)


function checkifemptyCOUNTRY(){
if (document.drop_list.SubCat.value=='')
document.drop_list.SubCat2.disabled=true
else
document.drop_list.SubCat2.disabled=false
}
if (document.all || document.getElementById)
setInterval("checkifemptyCOUNTRY()",100)


function checkifemptyLANGUAGE(){
if (document.drop_list.SubCat2.value=='')
document.drop_list.Go.disabled=true
else
document.drop_list.Go.disabled=false
}
if (document.all || document.getElementById)
setInterval("checkifemptyLANGUAGE()",100)

my html file is as follows:


<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>(Type a title for your page here)</title>

<script language="javascript" src="list2.js">
</script>

</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" onLoad="fillCategory();">

<FORM name="drop_list" action="yourpage.php" method="POST" >

<SELECT NAME="Category" onChange="SelectSubCat();" >
<Option value="">REGION SELECT</option>
</SELECT>&nbsp;
<SELECT id="SubCat" NAME="SubCat" onChange="SelectSubCat2();" >
<Option value="">COUNTRY SELECT</option>
</SELECT>&nbsp;
<SELECT id="SubCat2" NAME="SubCat2" >
<Option value="">LANGUAGE SELECT</option>
</SELECT>&nbsp;
<input name="Go" type="submit" value="GO!">
</form>

</body>

</html>

thanks for any help!