Solved

javascript working in IE but not in Firefox asp.net

Posted on 2010-08-27
7
693 Views
Last Modified: 2012-06-27
Hi,
I have a piece of code that doesn't work in firefox.
ISBNuseSame.Attributes.Add("onclick", "javascript:useSame(" + ISBNTextBox.ClientID + " , " + isbnValue + ");");

PPNuseSame.Attributes.Add("onclick", "javascript:useSame(" + PPNTextBox.ClientID + " , " + ppnValue + " );");

 on aspx page, i wrote a function:
 function useSame(textBoxId, textBoxValue) {
            alert(textBoxValue + textBoxId);textBoxId.value = textBoxValue;
          textBoxId.value = textBoxValue;            
        }
on ie, it works fine, on firefox, even the alert does not fire. Also, can you please tell me how do I five the textboxvalue to that textbox.
0
Comment
Question by:Dattu
[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
  • 4
  • 2
7 Comments
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 33544650
Hi

what type of controls are ISBNuseSame and PPNuseSame?
what are ISBNTextBox.ClientID and isbnValue, how are they being set?
does firefox give a javascript error and if so what is it?


0
 

Author Comment

by:Dattu
ID: 33544789
ISBN:
                   
                   
                   Use Same
                 
                     
               
               
                    PPN:
                   
                   Use Same
                   
               
<td>ISBN:</td>
                    <td><asp:TextBox ID="ISBNTextBox" runat="server" MaxLength="50"></asp:TextBox>
                   
                   <a href =# ID ="ISBNuseSame" runat = "server">Use Same</a> 
                  
                    </td> 
                </tr>
                <tr>
                    <td>PPN:</td>
                    <td><asp:TextBox ID="PPNTextBox" runat="server" MaxLength="20"></asp:TextBox>
                   <a href = # ID ="PPNuseSame" runat = "server">Use Same</a> </td>
                   
                </tr>

Open in new window

0
 

Author Comment

by:Dattu
ID: 33544798
the error given by firefox is:

Error: missing ; before statement
Source File: http://localhost:4257/Pages/CloneProduct.aspx?productid=68682
Line: 1, Column: 11
Source Code:
javascript:useSame'(ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ISBNTextBox , 1);'
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 38

Accepted Solution

by:
Tom Beck earned 125 total points
ID: 33544827
More than likely one or both of the values need to be in quotes for javascript:

ISBNuseSame.Attributes.Add("onclick", "javascript:useSame('" + ISBNTextBox.ClientID + "' , "' + isbnValue + "');");

Add single quotes inside double quotes where needed for string values.
0
 
LVL 17

Assisted Solution

by:jrm213jrm213
jrm213jrm213 earned 125 total points
ID: 33544896
from this:
javascript:useSame'(ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ISBNTextBox , 1);'

where are the ' coming from after useSame and all the way at the end ?

also

ctl00_ctl00_PageContentPlaceHolder_MainContentPlaceHolder_ISBNTextBox  I am guessing is the id of the control, you should need to put document.getElementById around it in your function in order to access it's value property, and tommyBoy is correct that you would need to have quotes around it in order to properly pass it.




ISBNuseSame.Attributes.Add("onclick", "javascript:useSame('" + ISBNTextBox.ClientID + "' , '" + isbnValue + "');");

PPNuseSame.Attributes.Add("onclick", "javascript:useSame('" + PPNTextBox.ClientID + "' , '" + ppnValue + "');");

on aspx page, i wrote a function:
function useSame(textBoxId, textBoxValue) {
            alert(textBoxValue + textBoxId);
          document.getElementById(textBoxId).value = textBoxValue;        
        }

Open in new window

0
 

Author Comment

by:Dattu
ID: 33544930
Sorry, what do you mean by adding single quotes inside double quotes. is this right?
   ISBNuseSame.Attributes.Add("onclick", "javascript:useSame('" + ISBNTextBox.ClientID + "' , '" + isbnValue + "');");
                    PPNuseSame.Attributes.Add("onclick", "javascript:useSame('" + PPNTextBox.ClientID + "' , '" + ppnValue + "');");
ISBNuseSame.Attributes.Add("onclick", "javascript:useSame('" + ISBNTextBox.ClientID + "' , '" + isbnValue + "');");
                    PPNuseSame.Attributes.Add("onclick", "javascript:useSame('" + PPNTextBox.ClientID + "' , '" + ppnValue + "');");

Open in new window

0
 

Author Comment

by:Dattu
ID: 33544956
got it. Thank You!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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)
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…

710 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