DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Onclick does not work in ie for multiple object (http://www.daniweb.com/forums/thread116126.html)

shaikh_mshariq Mar 28th, 2008 8:44 am
Onclick does not work in ie for multiple object
 
I have one table which is generated using javascript dynamically.
In have write one function which creates table dynamically
for IE i have writed
mytable.onClick=some_function();
for onclick event it works fine.
But when i generate more than one table dynamically using the same function then onclick does not work. If anyone have solution please reply asap. Thanx for spending your precious time.

Suomedia Mar 28th, 2008 9:58 am
Re: Onclick does not work in ie for multiple object
 
Usually the simplest thing to do is to click on the yellow ! icon in the bottom left of the browser window in IE. This will tell you the error. Better still, use Firefox and use the error console.

We can't see your code, so thats the best I can do.


Matti Ressler
Suomedia

ghostsquad Mar 28th, 2008 10:30 pm
Re: Onclick does not work in ie for multiple object
 
I agree. use the error console in firefox. most times, if it works in FF, it'll work in IE.

shaikh_mshariq Mar 30th, 2008 11:38 pm
Re: Onclick does not work in ie for multiple object
 
It works Very good in FireFox and Opera but in ie how ever it doesnot work for multiple objects

shaikh_mshariq Mar 30th, 2008 11:46 pm
Re: Onclick does not work in ie for multiple object
 
I have writed My code below for better understanding.This code works fine for one object but for more than one object it does not work or no error is occur.


  1. function getNodeTable(ip){
  2.         //alert("IE getNode Table");
  3.         var nodeTable=document.createElement("TABLE");
  4.         nodeTable.align='center';
  5.         var nodebody=document.createElement("TBODY");
  6.         var tableRow,tableCell;
  7.         nodebody.id='body'+ip;
  8.         nodeTable.appendChild(nodebody);
  9.         nodeTable.border=0;
  10.         nodeTable.id=ip;
  11.         nodeTable.name=ip;
  12.         tableRow=document.createElement("TR");
  13.         tableCell=document.createElement("TD");
  14.         tableCell.align='center';
  15.         tableCell.innerHTML='<img src=../images/waiting.gif height=62 width=88>';
  16.         tableRow.appendChild(tableCell);
  17.         nodebody.appendChild(tableRow);
  18.         tableRow=document.createElement("TR");
  19.         tableCell=document.createElement("TD");
  20.         tableCell.innerHTML='<div color=white align=center>Gathering Information <img src=../images/ajax-loader.gif></div>';//replace with actual message
  21.         tableRow.appendChild(tableCell);
  22.         nodebody.appendChild(tableRow);
  23.         var ipbkup="'"+ip+"'";
  24.         nodeTable.setAttribute('onClick','sendToServe('+ipbkup+')');//generic method in ajaxcode.js
  25.         nodeTable.onMouseOver="javascript:this.style.cursor='pointer'";
  26.         nodeTable.onLoad=sendRequestToServer(nodeTable,ip);
  27.         var newCell=document.createElement("DIV");
  28.         newCell.appendChild(nodeTable);
  29.         return newCell;
  30. }

shaikh_mshariq Mar 31st, 2008 1:30 am
Re: Onclick does not work in ie for multiple object
 
I have found the bug. Thanx for your help. My function gives me table in a div and i forgot to remove div while appending it to the document. I have writed code for only one object and it was not there for multiple object so that was the problem. Thanx for spending your valuable time friends.


All times are GMT -4. The time now is 8:02 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC