/    Sign up×
Community /Pin to ProfileBookmark

Desperate for help!

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=”http://jpltele.dnsmaster.net/compat.php”>http://jpltele.dnsmaster.net/compat.php</a>

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” “http://www.w3.org/TR/html4/loose.dtd“>

<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>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@James_GatkaMar 22.2006 — By way of example:

[CODE]<html>
<head>
<script type="text/javascript">

var zipCodes =[];
zipCodes["counties"] = ["Summit","Jefferson"];
zipCodes["Summit"] = ["44101","44107","44116","44135","44147"];
zipCodes["Jefferson"] = ["44221","44266","44270"];

function fillSelect(isValue,isNext){

isNext.length = 1;
var curr = zipCodes[isValue];
for (each in curr)
{
var nOption = document.createElement('option');
var isData = document.createTextNode(curr[each]);
nOption.setAttribute('value',curr[each]);
nOption.appendChild(isData);
isNext.appendChild(nOption);
}
}

function getValue(isValue){

var nextPg = isValue+".html";
alert(nextPg);
window.location.href = nextPg;
}

function init(){

fillSelect('counties',document.forms[0]['county']);
}

onload=init;

</script>
</head>
<body>

<form>
<select name='county' onchange="fillSelect(this.value,this.form['zipCode'])">
<option selected>Select Your County</option>
</select>
&nbsp
<Select name='zipCode' onchange="getValue(this.value)">
<option selected >Select Your Zip Code</option>
</select>
</form>

</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@xuviousauthorMar 22.2006 — Fantastic - Thank you for your help!
×

Success!

Help @xuvious spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...