this does't work in firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gm000
    New Member
    • Nov 2009
    • 11

    this does't work in firefox

    hi
    i m working in asp classic. The below code works in internet explorere but does't work in firefox. pleas help me

    Code:
    function DisplayMe(e)
    {
    //document.getElementById("CompName").value == 
    //alert(e.id);
    var elTableRow = document.getElementById(e.id);
    var elTableCells = elTableRow.getElementsByTagName("td");
    
    if (document.all) {
    document.getElementById("CompName").value=elTableCells[1].innerText;
    //var cell = elTableRow.getElementsByTagName("td")[1];
    //var content = elTableCells[1].innerText;
    //document.getElementById("CompName").value=elTableCells[1]
    
    document.getElementById("City").value=elTableCells[2].innerText;
    document.getElementById("Country").value=elTableCells[3].innerText;
    document.getElementById("Email").value=elTableCells[4].innerText;
    document.getElementById("Phone").value=elTableCells[5].innerText;
    document.getElementById("CompanyURL").value=elTableCells[6].innerText;
    document.getElementById("compDesc").value=elTableCells[7].innerText;
    document.getElementById("ID").value=elTableCells[1].id;
    //alert(elTableCells[2].innerText);
    
    }
    else
    
    {
    document.getElementById("CompName").textContent=elTableCells[1].textContent;
    document.getElementById("City").value=elTableCells[2].textContent;
    document.getElementById("Country").value=elTableCells[3].textContent;
    document.getElementById("Email").value=elTableCells[4].textContent;
    document.getElementById("Phone").value=elTableCells[5].textContent;
    document.getElementById("CompanyURL").value=elTableCells[6].textContent;
    document.getElementById("compDesc").value=elTableCells[7].textContent;
    document.getElementById("ID").value=elTableCells[1].id;
    
    alert(document.getElementById(e.id).textContent);
    }
    document.getElementById("CompName").textContent=elTableCells[1].textContent;
    
    }
    //--></script><!--webbot BOT="GeneratedScript" endspan -->
    Last edited by Dormilich; May 10 '10, 01:43 PM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    any messages in the Error Console?

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      I don't see any checking to ensure getElementById( ) actually returns something.

      You should also get errors in IE since you have a .textContent line outside of the else {} block. According to this: http://xn--www-5da33as14n.w3schools....om_element.asp IE doesn't support textContent

      Comment

      • gm000
        New Member
        • Nov 2009
        • 11

        #4
        Originally posted by Dormilich
        anny messages in the Error Console?
        there is no error wroking well but not onlclick event work in firefox.

        here is complelte code of my page.suggest me solution for firefox

        Code:
        <% if not session("username") = "OK" then response.redirect "../login.asp" %>
        <!--#include virtual="admin/cnn.asp" -->
        <html>
        <head>
        <meta http-equiv="Content-Language" content="en-us">
        <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
        <meta name="ProgId" content="FrontPage.Editor.Document">
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>STOCK STATUS REPORT</title>
        </head>
        
        <body>
        
        <p align="center"><font face="Arial Black" size="2">VENDOR MANAGEMENT</font></p>
        <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan -->
        <script Language="JavaScript" Type="text/javascript"><!--
        function FrontPage_Form1_Validator(theForm)
        {
        
          if (theForm.CompName.value == "")
          {
            alert("Please enter a value for the \"Title\" field.");
            theForm.CompName.focus();
            return (false);
          }
        
         
          return (true);
        }
        
        function DisplayMe(e)
        {
        //document.getElementById("CompName").value == 
        //alert(e.id);
        var elTableRow = document.getElementById(e.id);
        var elTableCells = elTableRow.getElementsByTagName("td");
        
        if (document.all) {
        document.getElementById("CompName").value=elTableCells[1].innerText;
        //var cell = elTableRow.getElementsByTagName("td")[1];
        //var content = elTableCells[1].innerText;
        //document.getElementById("CompName").value=elTableCells[1]
        
        document.getElementById("City").value=elTableCells[2].innerText;
        document.getElementById("Country").value=elTableCells[3].innerText;
        document.getElementById("Email").value=elTableCells[4].innerText;
        document.getElementById("Phone").value=elTableCells[5].innerText;
        document.getElementById("CompanyURL").value=elTableCells[6].innerText;
        document.getElementById("compDesc").value=elTableCells[7].innerText;
        document.getElementById("ID").value=elTableCells[1].id;
        //alert(elTableCells[2].innerText);
        
        }
        else
        
        {
        document.getElementById("CompName").textContent=elTableCells[1].textContent;
        document.getElementById("City").value=elTableCells[2].textContent;
        document.getElementById("Country").value=elTableCells[3].textContent;
        document.getElementById("Email").value=elTableCells[4].textContent;
        document.getElementById("Phone").value=elTableCells[5].textContent;
        document.getElementById("CompanyURL").value=elTableCells[6].textContent;
        document.getElementById("compDesc").value=elTableCells[7].textContent;
        document.getElementById("ID").value=elTableCells[1].id;
        
        alert(document.getElementById(e.id).textContent);
        }
        document.getElementById("CompName").textContent=elTableCells[1].textContent;
        
        }
        //--></script><!--webbot BOT="GeneratedScript" endspan -->
        
        <form method="POST" action="VendorMgt_2.asp" onSubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
          <div align="center">
            <center>
            
            
            	<table width="630" border="0" cellpadding="3" cellspacing="2" bordercolor="#111111"  ID="Table12" style="border-collapse: collapse">
                    <tbody>
                                  
                      <tr> 
                        <td class=blueBold colspan="4" height="15%" align="left" bgcolor="#DFEAFD">
                           <font face="Verdana, Arial, Helvetica, sans-serif" size="1">  <b> VENDOR INFORMATION: <b></font>
                       </td>
                       </tr>
                      
                      
                         <tr> 
                        <td class=blueBold width="10%" height="15%" align="left">
                              <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Title  :
                       </td>
                        <td class=blueBold width="40%" height="85%"> 
                            <font face="Verdana, Arial, Helvetica, sans-serif" size="1">
                          &nbsp;<input name="CompName" size="25" maxlength="50" value="<%=compName%>"  class="box">
                          </font>
                        </td>
         <!-- too long -->
        Last edited by Dormilich; May 11 '10, 06:21 AM. Reason: added [code] tags, cutting unnecessary code

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          in Firefox (and any other standard compliant browser) you need to assign an ID for document.getEle mentById() to work.

          PS. for JavaScript matters it is better to post the source code that you copy from the browser. any server side code will be processed on the server and doesn’t directly related to something that’s going on in the browser.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            I don't see any controls that reference the DisplayMe function?

            Comment

            Working...