?
Solved

Probelm with onChange on a MAC

Posted on 2009-07-12
9
Medium Priority
?
444 Views
Last Modified: 2013-12-07
Hi,

I have developed a admin site for at company (to IE7 & 8). However the company now uses a MAC with safari. They have encountered a problem with one of the script.

I run this in two diffent parts of the admin system (different index-files [PHP]):

<select onchange="location.href='?ref=getevents&SelectedMonth='+SelectedMonth.value+'&SelectedYear='+SelectedYear.value;" name="SelectedMonth">

in one of them there is no problem with the onchange, but in the other it wont change?!

Any ideas?
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 3

Expert Comment

by:laneway
ID: 24836899
First, here's a piece on information in case you don't already know.

To be able to view JavaScript errors in Safari, you must:
1. Quit Safari,
2. Open the terminal
3. Run the command below
4. Reopen Safari
5. Select "Show Error Console" from the "Develop" menu.
(Note that in old version of safari the menu was called "Debug".)
defaults write com.apple.Safari IncludeDebugMenu 1

Open in new window

0
 
LVL 3

Expert Comment

by:laneway
ID: 24836907
Try this code instead, it's more cross-browser compliant:

<select onchange="window.location.href='?ref=getevents&SelectedMonth='+this.value+'&SelectedYear='+document.getElementsByName('SelectedYear')[0].value;" name="SelectedMonth">

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 24837092
>>SelectedYear.value
I don't see where you have that element but try giving that element an id:

try:
 
<select onchange="var Y=document.getElementById('SelectedYear'); location.href='?ref=getevents&SelectedMonth=' + this.options[this.selectedIndex].value + '&SelectedYear=' + Y.options[Y.selectedIndex].value;" name="SelectedMonth">...</select>

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 24837682
And to make it a LOT simpler and TRULY compatible, use forms access - this assumes the other select has name="SelectedYear"


<select onchange="location.href='?ref=getevents&SelectedMonth='+this.options[this.selectedIndex].value+
'&SelectedYear='+this.form.SelectedYear.options[this.form.SelectedYear.selectedIndex].value;" name="SelectedMonth">
0
 
LVL 3

Author Comment

by:QualitySoftwareDevelopment
ID: 24837756
Thx guys,

I will test this later today and give you the feed back.
0
 
LVL 3

Expert Comment

by:laneway
ID: 24839964
Note:

// This used to be the best way to get the value of a select element:
this.options[this.selectedIndex].value
 
// However, this method is simpler and it now works in all major browsers (including IE6):
this.value

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24840008
However why change if the first one works in ALL browsers including obscure ones on mobiles or such?
0
 
LVL 3

Author Comment

by:QualitySoftwareDevelopment
ID: 24856965
Hi Guys,

I know I promised you an answer. However my time was prioritized otherwise for me :-) ... I have used mplungians solution since that was the easiest and the most simple for me to understand and use.

Since I'm not able to test the new code on a MAC until monday the ACCEPT of solution will not happen until then.

Thx again
0
 
LVL 3

Author Closing Comment

by:QualitySoftwareDevelopment
ID: 31602603
Simple and effective! THX!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question