Solved

Probelm with onChange on a MAC

Posted on 2009-07-12
9
443 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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
 
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 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

728 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