Solved

Probelm with onChange on a MAC

Posted on 2009-07-12
9
432 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
  • 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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now