[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Probelm with onChange on a MAC

Posted on 2009-07-12
9
Medium Priority
?
445 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
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.

656 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