Solved

OnChange Event not fireing in FireFox but works in IE

Posted on 2010-11-19
5
1,019 Views
Last Modified: 2013-12-07
I'm trying to change an image on the form whenever a value is selected from the dropdownlist box.  It works fine in Internet Explorer but the event doesn't seem to fire at all in FireFox.  I put the Alert message in the script to see and it never pops up in FireFox but does with IE.
function ChangeEdgeImage(this) {  

        var strColor = source.options.value;

        var strColorx = strColor.replace(/ /g, "_");

        document.getElementById('color_EdgePreview').src = "images/colors/" + strColorx  + ".jpg"; 

        document.getElementById('color_EdgeZoom').href = "images/colors/zoom/" + strColorx  + ".jpg";   

        document.getElementById('color_EdgeZoom').title = "Edge Color : " + strColorx;

        alert("Edge change");

    }



<asp:DropDownList class="product-attr-inside-color" ID="DropDownList1" 

    	runat="server" DataSourceID="dsColors" 

    	DataTextField="Color" DataValueField="Color" onchange="ChangeInsideImage(this);"> 

</asp:DropDownList

Open in new window

0
Comment
Question by:adaco
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 34178952
Seems function names are not matching.

function ChangeEdgeImage(this) // Line 1

onchange="ChangeInsideImage(this);" // Line 12
0
 
LVL 6

Author Comment

by:adaco
ID: 34186244
I have two functions ChangeInsideImage and ChangeEdgeImage they are exact duplicates but change different images on the screen.  I just copied the wrong field in my first post my bad.  This is the field

<asp:DropDownList class="product-attr-edge-color" 

    ID="DropDownList2" runat="server" DataSourceID="dsColors" 

    DataTextField="Color" DataValueField="Color" onchange="ChangeEdgeImage(this);">

</asp:DropDownList>

Open in new window

0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 34195509
Make sure if JavaScript is enabled in Firefox or not. This could be the reason for odd behavior of your application.
0
 
LVL 6

Accepted Solution

by:
adaco earned 0 total points
ID: 34199710
Removed the Source parameter and fully qualified the field on the form in the script.
function ChangeEdgeImage() {  

        var strColor = document.form1.DropDownList2.value;

        var strColorx = strColor.replace(/ /g, "_");

        document.getElementById('color_EdgePreview').src = "images/colors/" + strColorx  + ".jpg"; 

        document.getElementById('color_EdgeZoom').href = "images/colors/zoom/" + strColorx  + ".jpg";   

        document.getElementById('color_EdgeZoom').title = "Edge Color : " + strColorx;

        alert("Edge change");

    }



<asp:DropDownList class="product-attr-edge-color" 

    ID="DropDownList2" runat="server" DataSourceID="dsColors" 

    DataTextField="Color" DataValueField="Color" onchange="ChangeEdgeImage();">

</asp:DropDownList>

Open in new window

0
 
LVL 6

Author Closing Comment

by:adaco
ID: 34224649
Found Solution internally
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 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.
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…

706 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

20 Experts available now in Live!

Get 1:1 Help Now