Link to home
Start Free TrialLog in
Avatar of Dattu
DattuFlag for United States of America

asked on

javascript working in IE but not in Firefox asp.net

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.
Avatar of jrm213jrm213
jrm213jrm213
Flag of United States of America image

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?


Avatar of Dattu

ASKER

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

Avatar of Dattu

ASKER

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);'
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dattu

ASKER

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

Avatar of Dattu

ASKER

got it. Thank You!