Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Firefox dynamic menu fix.

Status
Not open for further replies.

saurdo

Programmer
Oct 9, 2006
2
US
I copied this code straight from a book i'm learning from and it works somewhat the way i want it to but it won't reset the catagory field when you choose a new language. This is only a problem in Firefox, it works in all the other browsers I tried.

Here's the code.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
actionscript = new Array('Image Handling', 'File Handling', 'Games', 'Server Side', 'Animation', 'Preloaders')
asp = new Array('Database', 'Content Management', 'Search Engines', 'Form Handlers')
css = new Array('IE Fixes', 'Navigation', 'Rollovers', 'Menus', 'Image Effects')
javascript = new Array('Image Effects', 'Text Effects', 'Document Effects', 'Forms', 'Navigations', 'Ajax')
perl = new Array('Image Manipulation', 'File managment', 'Content managment', 'Form Handlers')
php = new Array('Content Managment', 'File managment', 'Galleries', 'Database', 'Form Handlers')
other = new Array('Python', 'Ruby', 'Other Others')
xml = new Array('Parsers', 'Content Managment', 'User Interface', 'Form Handlers')


function getcatagory(language){
//clear out the current options
for(i=document.form1.catagory.options.length-1; i >0; i--)
{
document.form1.catagory.options.remove(i)
}
lang = language.options[
language.selectedIndex].value
if (lang != "") {
if (lang == '1'){
for (i=1; i<=actionscript.length;i++) {
document.form1.catagory.options[i] =
new Option(actionscript[i-1])
}
}
if (lang == '2'){
for (i=1; i<=asp.length;i++){
document.form1.catagory.options[i] =
new Option(asp[i-1])
}
}
if (lang == '3'){
for (i=1; i<=css.length;i++){
document.form1.catagory.options[i] =
new Option(css[i-1])
}
}
if (lang == '4'){
for (i=1; i<=javascript.length;i++){
document.form1.catagory.options[i] =
new Option(javascript[i-1])
}
}
if (lang == '5'){
for (i=1; i<=perl.length;i++){
document.form1.catagory.options[i] =
new Option(perl[i-1])
}
}
if (lang == '6'){
for (i=1; i<=php.length;i++){
document.form1.catagory.options[i] =
new Option(php[i-1])
}
}
if (lang == '7'){
for (i=1; i<=other.length;i++){
document.form1.catagory.options[i] =
new Option(other[i-1])
}
}
if (lang == '8'){
for (i=1; i<=xml.length;i++){
document.form1.catagory.options[i] =
new Option(xml[i-1])
}
}
}
}
</script>
</head>
<body onload="document.form1.language.selectedIndex=0">
<form action="" name="form1">
<select name="language" onchange="getcatagory(this)">
<option value="0">Choose Language</option>
<option value="1">Action Script</option>
<option value="2">ASP</option>
<option value="3">CSS</option>
<option value="4">JavaScript</option>
<option value="5">Perl</option>
<option value="6">PHP</option>
<option value="7">Other</option>
<option value="8">XML</option>
</select>
<select name="catagory">
<option value="0">Select Catagory</option>
</select>
<br>
<input type="submit" value="submit">
</form>
</body>
</html>

Thanks for any help!
 
What does Firefox's Javascript console tell you the error is?

Lee
 
Firefox has a javascript console?!

Oh well, some people on another forum helped me out. Thanks for your interest anyway!
 
>Firefox has a javascript console?!
Has it not?
>Oh well, some people on another forum helped me out. Thanks for your interest anyway!
Oh well, thanks for your interest in Tek-tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top