By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,352 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,352 IT Pros & Developers. It's quick & easy.

this does't work in firefox

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

Expand|Select|Wrap|Line Numbers
  1. function DisplayMe(e)
  2. {
  3. //document.getElementById("CompName").value == 
  4. //alert(e.id);
  5. var elTableRow = document.getElementById(e.id);
  6. var elTableCells = elTableRow.getElementsByTagName("td");
  7.  
  8. if (document.all) {
  9. document.getElementById("CompName").value=elTableCells[1].innerText;
  10. //var cell = elTableRow.getElementsByTagName("td")[1];
  11. //var content = elTableCells[1].innerText;
  12. //document.getElementById("CompName").value=elTableCells[1]
  13.  
  14. document.getElementById("City").value=elTableCells[2].innerText;
  15. document.getElementById("Country").value=elTableCells[3].innerText;
  16. document.getElementById("Email").value=elTableCells[4].innerText;
  17. document.getElementById("Phone").value=elTableCells[5].innerText;
  18. document.getElementById("CompanyURL").value=elTableCells[6].innerText;
  19. document.getElementById("compDesc").value=elTableCells[7].innerText;
  20. document.getElementById("ID").value=elTableCells[1].id;
  21. //alert(elTableCells[2].innerText);
  22.  
  23. }
  24. else
  25.  
  26. {
  27. document.getElementById("CompName").textContent=elTableCells[1].textContent;
  28. document.getElementById("City").value=elTableCells[2].textContent;
  29. document.getElementById("Country").value=elTableCells[3].textContent;
  30. document.getElementById("Email").value=elTableCells[4].textContent;
  31. document.getElementById("Phone").value=elTableCells[5].textContent;
  32. document.getElementById("CompanyURL").value=elTableCells[6].textContent;
  33. document.getElementById("compDesc").value=elTableCells[7].textContent;
  34. document.getElementById("ID").value=elTableCells[1].id;
  35.  
  36. alert(document.getElementById(e.id).textContent);
  37. }
  38. document.getElementById("CompName").textContent=elTableCells[1].textContent;
  39.  
  40. }
  41. //--></script><!--webbot BOT="GeneratedScript" endspan -->
May 10 '10 #1
Share this Question
Share on Google+
5 Replies


Dormilich
Expert Mod 5K+
P: 8,639
any messages in the Error Console?
May 10 '10 #2

Plater
Expert 5K+
P: 7,872
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
May 10 '10 #3

P: 11
@Dormilich
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

Expand|Select|Wrap|Line Numbers
  1. <% if not session("username") = "OK" then response.redirect "../login.asp" %>
  2. <!--#include virtual="admin/cnn.asp" -->
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Language" content="en-us">
  6. <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
  7. <meta name="ProgId" content="FrontPage.Editor.Document">
  8. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  9. <title>STOCK STATUS REPORT</title>
  10. </head>
  11.  
  12. <body>
  13.  
  14. <p align="center"><font face="Arial Black" size="2">VENDOR MANAGEMENT</font></p>
  15. <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan -->
  16. <script Language="JavaScript" Type="text/javascript"><!--
  17. function FrontPage_Form1_Validator(theForm)
  18. {
  19.  
  20.   if (theForm.CompName.value == "")
  21.   {
  22.     alert("Please enter a value for the \"Title\" field.");
  23.     theForm.CompName.focus();
  24.     return (false);
  25.   }
  26.  
  27.  
  28.   return (true);
  29. }
  30.  
  31. function DisplayMe(e)
  32. {
  33. //document.getElementById("CompName").value == 
  34. //alert(e.id);
  35. var elTableRow = document.getElementById(e.id);
  36. var elTableCells = elTableRow.getElementsByTagName("td");
  37.  
  38. if (document.all) {
  39. document.getElementById("CompName").value=elTableCells[1].innerText;
  40. //var cell = elTableRow.getElementsByTagName("td")[1];
  41. //var content = elTableCells[1].innerText;
  42. //document.getElementById("CompName").value=elTableCells[1]
  43.  
  44. document.getElementById("City").value=elTableCells[2].innerText;
  45. document.getElementById("Country").value=elTableCells[3].innerText;
  46. document.getElementById("Email").value=elTableCells[4].innerText;
  47. document.getElementById("Phone").value=elTableCells[5].innerText;
  48. document.getElementById("CompanyURL").value=elTableCells[6].innerText;
  49. document.getElementById("compDesc").value=elTableCells[7].innerText;
  50. document.getElementById("ID").value=elTableCells[1].id;
  51. //alert(elTableCells[2].innerText);
  52.  
  53. }
  54. else
  55.  
  56. {
  57. document.getElementById("CompName").textContent=elTableCells[1].textContent;
  58. document.getElementById("City").value=elTableCells[2].textContent;
  59. document.getElementById("Country").value=elTableCells[3].textContent;
  60. document.getElementById("Email").value=elTableCells[4].textContent;
  61. document.getElementById("Phone").value=elTableCells[5].textContent;
  62. document.getElementById("CompanyURL").value=elTableCells[6].textContent;
  63. document.getElementById("compDesc").value=elTableCells[7].textContent;
  64. document.getElementById("ID").value=elTableCells[1].id;
  65.  
  66. alert(document.getElementById(e.id).textContent);
  67. }
  68. document.getElementById("CompName").textContent=elTableCells[1].textContent;
  69.  
  70. }
  71. //--></script><!--webbot BOT="GeneratedScript" endspan -->
  72.  
  73. <form method="POST" action="VendorMgt_2.asp" onSubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
  74.   <div align="center">
  75.     <center>
  76.  
  77.  
  78.         <table width="630" border="0" cellpadding="3" cellspacing="2" bordercolor="#111111"  ID="Table12" style="border-collapse: collapse">
  79.             <tbody>
  80.  
  81.               <tr> 
  82.                 <td class=blueBold colspan="4" height="15%" align="left" bgcolor="#DFEAFD">
  83.                    <font face="Verdana, Arial, Helvetica, sans-serif" size="1">  <b> VENDOR INFORMATION: <b></font>
  84.                </td>
  85.                </tr>
  86.  
  87.  
  88.                  <tr> 
  89.                 <td class=blueBold width="10%" height="15%" align="left">
  90.                       <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Title  :
  91.                </td>
  92.                 <td class=blueBold width="40%" height="85%"> 
  93.                     <font face="Verdana, Arial, Helvetica, sans-serif" size="1">
  94.                   &nbsp;<input name="CompName" size="25" maxlength="50" value="<%=compName%>"  class="box">
  95.                   </font>
  96.                 </td>
  97.  <!-- too long -->
May 11 '10 #4

Dormilich
Expert Mod 5K+
P: 8,639
in Firefox (and any other standard compliant browser) you need to assign an ID for document.getElementById() 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.
May 11 '10 #5

Plater
Expert 5K+
P: 7,872
I don't see any controls that reference the DisplayMe function?
May 11 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.