Hi everyone please be patient im new to javascript – but i am trying!!!
What id like to achieve is a comination of two different scrips both of which work independently.
it may help if you see the page im working on: <a href=”
The idea is that the customer select the phone manufacturer from the first drop down, the java the uses an ‘array’ to populate the second list (models) depending on the choice in the first list. What I then want to happen is that when the customer clicks on a particular model in the second list they are taken to a page specific to model.
I have tried using the value=”model.htm” tag in the array that is populated in the second menu but that does no work
Im sure the answer is simple but as a newbie i just dont have the experience to look at the code and work through this!
Ive included the code below to help. If i can porvide any further info to help please ask.
====================code below==========================
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “
<html>
<head>
<title>Phone Chooser</title>
</head>
<body>
<script language=”JavaScript”>
<!–
var threeComArray = new Array(“(‘Select model’,”,true,true)”,
“(‘model 1’)”,
“(‘model 2’)”,
“(‘model 3’)”,
“(‘model 4’)”);
var AastraTelecomArray = new Array(“(‘Select model’,”,true,true)”,
“(‘model 1’)”,
“(‘model 2’)”,
“(‘model 3’)”,
“(‘model 4’)”);
var AgfeoArray = new Array(“(‘Select model’,”,true,true)”,
“(‘model 1’)”,
“(‘model 2’)”,
“(‘model 3’)”,
“(‘model 4’)”);
var AlcatelArray = new Array(“(‘Select model’,”,true,true)”,
“(‘model 1’)”,
“(‘model 2’)”,
“(‘model 3’)”,
“(‘model 4’)”);
var AllnetArray = new Array(“(‘Select model’,”,true,true)”,
“(‘Australia’)”,
“(‘New Zealand’)”,
“(‘Other’)”);
var AltigenArray = new Array(“(‘Select model’,”,true,true)”,
“(‘model 1’)”,
“(‘model 2’)”,
“(‘model 3’)”,
“(‘model 4’)”);
var AmstradArray = new Array(“(‘Select model’,”,true,true)”,
“(‘model 1’)”,
“(‘model 2’)”,
“(‘model 3’)”,
“(‘model 4’)”);
var AscomArray = new Array(“(‘Select model’,”,true,true)”,
“(‘model 1’)”,
“(‘model 2’)”,
“(‘model 3’)”,
“(‘model 4’)”);
function populatemodel(inForm,selected) {
var selectedArray = eval(selected + “Array”);
while (selectedArray.length < inForm.model.options.length) {
inForm.model.options[(inForm.model.options.length – 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
eval(“inForm.model.options[i]=” + “new Option” + selectedArray[i]);
}
if (inForm.compat.options[0].value == ”) {
inForm.compat.options[0]= null;
if ( navigator.appName == ‘Netscape’) {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0);
}
else {
if (navigator.platform == ‘Win32’ || navigator.platform == ‘Win16’) {
window.history.go(0);
}
}
}
}
}
function populateUSstate(inForm,selected) {
var stateArray = new Array(“(‘Select State’,”,true,true)”,
“(‘Alabama’)”,
“(‘Alaska’)”,
“(‘Arizona’)”,
“(‘Arkansas’)”,
“(‘California’)”,
“(‘Colorado’)”,
“(‘Connecticut’)”,
“(‘Delaware’)”,
“(‘Columbia’)”,
“(‘Florida’)”,
“(‘Georgia’)”,
“(‘Hawaii’)”,
“(‘Idaho’)”,
“(‘Illinois’)”,
“(‘Indiana’)”,
“(‘Iowa’)”,
“(‘Kansas’)”,
“(‘Kentucky’)”,
“(‘Louisiana’)”,
“(‘Maine’)”,
“(‘Maryland’)”,
“(‘Massachusetts’)”,
“(‘Michigan’)”,
“(‘Minnesota’)”,
“(‘Mississippi’)”,
“(‘Missouri’)”,
“(‘Montana’)”,
“(‘Nebraska’)”,
“(‘Nevada’)”,
“(‘New Hampshire’)”,
“(‘New Jersey’)”,
“(‘New Mexico’)”,
“(‘New York’)”,
“(‘North Carolina’)”,
“(‘North Dakota’)”,
“(‘Ohio’)”,
“(‘Oklahoma’)”,
“(‘Oregon’)”,
“(‘Pennsylvania’)”,
“(‘Rhode Island’)”,
“(‘South Carolina’)”,
“(‘South Dakota’)”,
“(‘Tennessee’)”,
“(‘Texas’)”,
“(‘Utah’)”,
“(‘Vermont’)”,
“(‘Virginia’)”,
“(‘Washington’)”,
“(‘West Virginia’)”,
“(‘Wisconsin’)”,
“(‘Wyoming’)”);
if (selected == ‘USA’) {
for (var i=0; i < stateArray.length; i++) {
eval(“inForm.model.options[i]=” + “new Option” + stateArray[i]);
}
if ( navigator.appName == ‘Netscape’) {
if (parseInt(navigator.appVersion) < 4) {
window.history.go(0)
}
else {
if (navigator.platform == ‘Win32’ || navigator.platform == ‘Win16’) {
window.history.go(0)
}
}
}
}
else {
}
if (selected == ‘Other’) {
newmodel = “”;
while (newmodel == “”){
newmodel=prompt (“Please enter your phone model.”, “”);
}
if (newmodel != null) {
inForm.model.options[(inForm.model.options.length-1)]=new Option(newmodel,newmodel,true,true);
inForm.model.options[inForm.model.options.length]=new Option(‘Other, not listed’,’Other’);
}
}
if(inForm.model.options[0].text == ‘Select model’) {
inForm.model.options[0]= null;
}
}
//–>
</script>
</head>
<center><h1>Phone Compatability Chooser V2.01</h1></center>
<p>Lets try again shall we – bloody plantronics only went and changed the goal posts!</p>
<center>
<script language=”JavaScript” type=”text/javascript”>
function Linkup()
{
var number = document.compat.model.selectedIndex;
location.href = document.compat.model.options[number].value;
}
</script>
<form name=”compat”>
<select name=”compat” onChange=”populatemodel(document.compat,document.compat.compat.options[document.compat.compat.selectedIndex].value)”>
<option selected value=”>Select Manufacturer</option>
<option value=”threeCom”>3Com</option>
<option value=”AastraTelecom”>Aastra Telecom</option>
<option value=”Agfeo”>Agfeo</option>
<option value=”Alcatel”>Alcatel</option>
<option value=”Allnet”>Allnet</option>
<option value=”Altigen”>Altigen</option>
<option value=”Amstrad”>Amstrad</option>
</select>
<select name=”model” onChange=”Linkup(this.form).php”>
<option value=”><——————–</option>
</select>
</form>
</center>
</html>