...

View Full Version : Regarding Element adding via select box



SyntaxError
09-04-2007, 11:15 PM
Today I have been trying to write a simple script. With selecting a certain "Option" via the Select Box, I'm trying to make the second Select Box correspond to the first. Sounds simple enough, though I'm finding some difficulties.

Here is the basic:


<html>

<head>
<title>Index</title>
<meta name="robots" content="noindex,nofollow" />
<style type="text/css">
</style>
<head>

<body>
<script type="text/javascript">
fuction country()
{
var country;
var a=document.getElementById("us");
var b=document.getElementById("can");
var c=document.getElementById("misc");

if (country==a) document.write("<select><option>New

Hampshire</option><option>Alabama</option<option>Alaska</option></select>");
else if (country==b) document.write("<select><option>New

Brunswick</option><option>Alberta</option<option>Quebec</option></select>");
else (country==c) document.write("<select><option>England</option><option>France</option<option>China</option></select>");
}
</script>

<select>
<option id="us" onselect="country()">United States</option>
<option id="can" onselect="country()">Canada</option>
<option id="misc" onselect="country()">Other</option>
</select>

<select>
</select>
</body>

</html>

Many thanks in advance for any suggestions correcting my errors.

Aradon
09-05-2007, 03:03 AM
Java != javascript. Moved ^^

chump2877
09-05-2007, 04:24 AM
I think I already answered this question here?: http://codingforums.com/showthread.php?t=122977

:eek:

_Aerospace_Eng_
09-05-2007, 04:39 AM
http://www.dynamicdrive.com/dynamicindex16/chainedselects/index.htm



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum