Solved

Probelm with onChange on a MAC

Posted on 2009-07-12
9
430 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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 3

Author Comment

by:QualitySoftwareDevelopment
Comment Utility
Thx guys,

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

Expert Comment

by:laneway
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Simple and effective! THX!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
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.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
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 +…

771 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

11 Experts available now in Live!

Get 1:1 Help Now