Create link in an html table with javascript -
I am using the following code to add columns to the dynamically in an HTML table:
var TblHeadObj = window.opener.document.getElementById ("Maintenance"). THead; Var j = 0; While (j & lt; fname.length) {if (tblHeadObj! = Null) {for (var h = 0; h & lt; tblHeadObj.rows.length; h ++) {var newTH = window.opener.document CreateElement ('th'); TblHeadObj.rows [bell] .appendChild (newTH); //newTH.innerHTML='[theotherro:'+h+'cell:'+(tblHeadObj.rows[h].cells.length-1)}} var tblBodyObj = window.opener.document.getElementById ("Maintenance"). TBodies [0]; // var (for var i = 0; i & lt; tblBodyObj.rows.length; i ++) {var newCell = tblBodyObj.rows [0] .inertCell (-1); Var newCell = tblBodyObj.rows [0] .inertCell (-1); // newCell.innerHTML = (tblBodyObj.rows [0] .cells.length - 1) NewCalendarHTML = fname [j]; J ++; } Now I want to make the column as a link. How can I do this?
Thanks
As noted by other people, it is not quite clear What is the meaning of "creating columns as links"? However, we have become addicted to the real problem in the form of a community and to provide solutions based on that assumption. As we gain experience in dealing with the most vague questions, our ESP skills become more respected.
It appears that you are creating an HTML table through DOM methods, I would agree that you want to create a link in the tableclub created and here is my suggestion:
For the purpose of creating any element that you need, use the same createElement method For example, a link (anchor) can be made with the following code:
Var link = document.createElement ("a"); Link.setAttribute ("href", "http://www.microsoft.com") link.className = "some CSS class"; // Only for IE, you can only set the inner text of the node // The code below, however, should work on all browsers. Var linkText = document.createTextNode ("click me"); Link.appendChild (LinkText); // Add links to pre-made tableclines newCell.appendChild (link); Alternatively, you can also set the inner HTML of the tableclass because @ Anonymous has suggested.
Comments
Post a Comment