Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2010, 10:27 PM
Registered User
 
Join Date: Sep 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Table Cells Links

Hi All,

I tried to add links to open local xml files in browser by clicking 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");

}
 
Old July 25th, 2010, 06:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And the problem is? I would help if you explained what exactly you need help with. I don't think people will copy the code, run it in a browser, create local XML files and then try to figure out what your problem could be.... Detailed questions == detailed answers.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old July 25th, 2010, 10:09 AM
Registered User
 
Join Date: Sep 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
And the problem is? I would help if you explained what exactly you need help with. I don't think people will copy the code, run it in a browser, create local XML files and then try to figure out what your problem could be.... Detailed questions == detailed answers.

Imar
Hi Imar,

I am really surprised that the first sentences did not clearly understood.

"I tried to add links to open local xml files in browser by clicking 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)."


I did not give my complete code, I gave my function to male issue more understanding and not for copying and run.

To clarify it further, Issue#1: I have multiple xml files in my local directory say at C:\AAA\ Test Me Now.xml, Test After.xml. I need to open that file in browser through my application. I can open that by document.write(). But I want it formatted as in table. I need to display file names as Hyperlinks.
Issue#2: When file names have blank spaces IE does not open them.

Can you suggest now?
 
Old July 25th, 2010, 10:57 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Are they true XML files? In that case, you may want to look into XSLT; it's designed to transform XML documents to other formats such as HTML...

Other than that, I can't recommend much as it's still unclear to me what you're trying to do....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old July 27th, 2010, 09:32 AM
Registered User
 
Join Date: Sep 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
Are they true XML files? In that case, you may want to look into XSLT; it's designed to transform XML documents to other formats such as HTML...

Other than that, I can't recommend much as it's still unclear to me what you're trying to do....

Imar
Hi Imar,
Thanks for your efforts in trying to understand the issue, I got reply from tsuji.
http://www.tek-tips.com/viewthread.c...1613422&page=1
My issue solved.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Table cells as links gjeardle HTML Code Clinic 16 January 24th, 2007 12:08 PM
Dynamic Links in Crystal Reports (VS.Net 2005) harini311 Crystal Reports 0 September 9th, 2006 10:44 PM
Arrange dynamic cells... Roshu Javascript How-To 1 January 11th, 2005 06:55 AM
Table Links samdavis HTML Code Clinic 2 November 30th, 2004 06:38 AM
Entering data to dynamic table cells weebadbilly XSLT 0 June 30th, 2004 07:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.