Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Table Cell Hyper Link 1

Status
Not open for further replies.

CharlyBen

Programmer
Jul 23, 2010
3
US
Hi All,

I tried to add links to open local xml files in browser in a dynamic table cells. I need help. I tried all ways but I think I miss something.
I can open them without table just by document.write(xmlfile location).
Here is my code. please help.
function showResultsTable(searched, srchedname) {
// get the reference for the body
var mybody = document.getElementsByTagName("body")[0];

// creates a <table> element and a <tbody> element
mytable = document.createElement("table");
mytable.setAttribute('id', 'resulttable');
mytablebody = document.createElement("tbody");

// creating all cells
var mycurrent_cell = new Array();

for(var j = 0; j < srchedname.length; j++) {
// creates a <tr> element
mycurrent_row = document.createElement("tr");

mycurrent_cell[0] = document.createElement("td");
currenttext = document.createTextNode(j);
mycurrent_cell[0].appendChild(currenttext);
mycurrent_row.appendChild(mycurrent_cell[0]);


mycurrent_cell[1] = document.createElement("td");
link = document.createElement("a");
link.name = ""+srchedname[j]);
link.href = "C:\\AAA\\TestCasesList.xml";
mycurrent_cell[1].appendChild(link);
mycurrent_row.appendChild(mycurrent_cell[1]);


mycurrent_cell[2] = document.createElement("td");
currenttext = document.createTextNode(searched[j]);
mycurrent_cell[2].appendChild(currenttext);
mycurrent_row.appendChild(mycurrent_cell[2]);

// appends the row <tr> into <tbody>
mytablebody.appendChild(mycurrent_row);
}
// appends <tbody> into <table>
mytable.appendChild(mytablebody);
// appends <table> into <body>
mybody.appendChild(mytable);
// sets the border attribute of mytable to 2;
mytable.setAttribute("border", "2");

}
 
[tt]mycurrent_cell[1] = document.createElement("td");
link = document.createElement("a");
[red]//[/red]link.name = ""+srchedname[j][highlight])[/highlight];
[blue]link.name = srchedname[j];[/blue]
link.href = "C:\\AAA\\TestCasesList.xml";
//adding innerHTML same as href or something description if you like
[blue]link.innerHTML="C:\\AAA\\TestCasesList.xml";[/blue]
mycurrent_cell[1].appendChild(link);
mycurrent_row.appendChild(mycurrent_cell[1]);
[/tt]
 
Hi tsuji,
Thank you very much for solving the issue. But I face an issue where I can not open the xml files with blank spaces in their names. Ex: Test Additional Fee.xml. I replced the blanks with %20 but of no use. It does not solve the issue.
I really appreciate your knowledge and help in this regard.
 
>I can not open the xml files with blank spaces in their names. Ex: Test Additional Fee.xml.
You can script it like this.
[tt] link.href = "C:\\AAA\\Test\x20Additional\x20Fee.xml";
link.innerHTML = "C:\\AAA\\Test\x20Additional\x20Fee.xml"; //or some descriptive string[/tt]
 
Hi tsuji,

Thank you very much for the help. It solved my issue.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top