Filling 2nd dropdown by choice in first

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2006
Posts: 7
Reputation: DNRSmitty is an unknown quantity at this point 
Solved Threads: 0
DNRSmitty DNRSmitty is offline Offline
Newbie Poster

Filling 2nd dropdown by choice in first

 
0
  #1
Jan 8th, 2007
Here is some more code that I tried, but failed to get to work. Anybody know what I'm doing wrong? I put in some displays to see if the onChange command was trying to execute the function, and it was.:eek:

[ TAG !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

<%@LANGUAGE="Javascript"%>
<html>
<head>
<title>Load Dropdown</title>
<script language="JavaScript">
<!--
var tennisplayers= new array("Safin","Andre Agassi","Pete Sampras","Anna Kournik","Martina Hingis");
var cricketplayers= new array("Sachin Tendulkar","Steve Waugh","Brian Lara","Sir Bradman");
function set_player(){
alert("Im here!!!!!")
var select_sport= document.form1.sport;
var select_player= document.form1.player;
var selected_sport= select_sport.options[select_sport.selectedIndex].value;
select_player.options.length=0;
if (selected_sport == "tennis"){
alert("Im at tennis")
for(var i=0; i < tennisplayers.length; i++)
select_player.options[select_player.options.length] = new Option(tennisplayer[i]);
}
if (selected_sport == "cricket"){
for(var i=0; i < cricketplayers.length; i++)
select_player.options[select_player.options.length] = new option(cricketplayer[i]);
}
}
-->
</script>
</head>
<body>
<form name="form1" method=">
<table align="center" cellpadding="0" cellspacing="0" border="2" bordercolor="#000066">
<tr valign="baseline" bgcolor="#66FFFF">
<td nowrap align="left" width="182" valign="top">
<div align="left"><b><font size="2" face="Arial, Helvetica, sans-serif">SPORT</font></b></div></td>
<td width="219" nowrap="false"><font size="2" face="Times New Roman, Times, serif">
<select name="sport" onChange="set_player();" size="1">
<option value="tennis">Choose Sport
<option value="tennis">Tennis
<option value="cricket">Cricket
</select>
</tr>
<tr valign="baseline" bgcolor="#66FFFF">
<td nowrap align="right" width="182" valign="top">
<div align="left"><b><font size="2" face="Arial, Helvetica, sans-serif">PLAYERS</font></b></div></td>
<td width="219" nowrap="false"><font size="2" face="Times New Roman, Times, serif">
<select name="player">
<option> </option>
<option> </option>
<option> </option>
<option> </option>
<option> </option>
<option> </option>
</select>
</tr>
</form>
</body>
</html>

END TAG!!!!!!!!!!!!!!!!!!!!!!!!!]
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 79
Reputation: nikkiH is an unknown quantity at this point 
Solved Threads: 4
nikkiH's Avatar
nikkiH nikkiH is offline Offline
Junior Poster in Training

Re: Filling 2nd dropdown by choice in first

 
0
  #2
Jan 8th, 2007
Javascript is a case-sensitive language.
Array is upper case A. Use new Array().
You have other errors like that.
VB is not case-sensitive. Javascript is.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 7
Reputation: DNRSmitty is an unknown quantity at this point 
Solved Threads: 0
DNRSmitty DNRSmitty is offline Offline
Newbie Poster

Re: Filling 2nd dropdown by choice in first

 
0
  #3
Jan 8th, 2007
Thank you, I didn't know that. I'm a Paradox/MS Access programmer that just got thrown into Javascript/SQL DB's.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 7
Reputation: DNRSmitty is an unknown quantity at this point 
Solved Threads: 0
DNRSmitty DNRSmitty is offline Offline
Newbie Poster

Re: Filling 2nd dropdown by choice in first

 
0
  #4
Jan 8th, 2007
Originally Posted by nikkiH View Post
Javascript is a case-sensitive language.
Array is upper case A. Use new Array().
You have other errors like that.
VB is not case-sensitive. Javascript is.
[I corrected new Array, and new Option, I'm not sure what else I've missed or what else is suppost to be lower or upper case. Do you see anything else that's wrong? Thank you for helping me. I REALLY APPRECIATE IT! ]
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC