Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

javascript working in IE but not in Firefox asp.net

Posted on 2010-08-27
7
Medium Priority
?
695 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 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 500 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 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…

715 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