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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code not working in FireFox!!! PLEASE HELP!!!!!!!!!!!

Status
Not open for further replies.

ppepin

IS-IT--Management
Mar 13, 2001
36
0
0
US
Ok, I've been struggling with this for the last 2 days. I've finally narrowed down my problem and was able to create a simple HTML page to illustrate this.

Can anybody tell me why the following code works in IE (all versions) and not in Firefox, Safari, etc?

<HTML>
<BODY>
<INPUT type='hidden' id='year_key' name='year_key' value='2005'>
<a href="#" class="" id="tab6">
<select id="sel_year" name="sel_year" size="1" onchange='select_year();'>
<option value="2013">2013
<option value="2012">2012
<option value="2011">2011
<option value="2010">2010
<option value="2009">2009
<option value="2008">2008
<option value="2007">2007
<option value="2006">2006
<option selected value="2005">2005
<option value="2004">2004
<option value="2003">2003
<option value="2002">2002
<option value="2001">2001
<option value="2000">2000
</select>
</a>

</BODY>
</HTML>

<SCRIPT language='javascript'>
function select_year() {
alert("select year");
document.getElementById("year_key").value = document.getElementById("sel_year").value;
}
</SCRIPT>
 
Because you are surrounding your drop down in a link. Why are you surrounding your drop down in a link?

The Link effectively kills the onchange event of the drop down because it takes precedence over it. When you click on the drop down you activate the like before the drop down's onchange event has a chance to fire.

IE simply ignores the link around the drop down.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
IE may ignore teh link around the dropdown, but it retains the style attributes of the id="tab6".

Essentially, the style attributes of id="tab6" makes the link look like a tab in a folder.

I have 6 tabs, years 2000 - 2006, and a seventh tab that I want to be a dropdown (above example), for all the years outside 2000-2006.

 
Surround it with a DIV or a span instead of a link, and give it the same tab6 style.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
I had to make some adjustments to my stylesheet, but the <SPAN> seems to be working.

Thanks for the suggestion.
 
Given you worked more that 2 days on this problem ppepin - how about awarding some recognition (a common way to do this is by clicking the purple star link) to vacunita for his assistance!

Nicely spotted, vacunita.

Jeff

[tt]Visit my blog [!]@[/!] Visit Code Couch [!]@[/!] [/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
how about awarding some recognition

Especially so given the apparent urgency the problem had (apparent by the rather annoying "!!! PLEASE HELP!!!!!!!!!!!" in the title, although quite why people who didn't need help would post anyway...)

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info:
The Out Atheism Campaign
 
I would pass the option value to the function and use that parameter in your equals statement.

Also, make sure each option tag is closed. Your code does not show it as closed.


SMS Marketing - Coupons to Mobile Phones - Text Message Coupons
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top