This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i to put hyperlink in javascript table

 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i using the innerHTML to create the table like this::


i do i put in the hyperlink in the table value???
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i try to use the document.write but this will make my pages cannot display out just the value of the document.write can be display out
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hvae you tried to write out a link syntax to a string and stick it in the innerHTML? You can also look into document.createElement("a") with appendChild();

Eric
 
Linda Walters
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever you are dealing with the dynamic creation of tables in HTML or with dynamically modifying the data within them, you need to be aware of some quirks (some would say bugs) in the way that Microsoft Internet Explorer handles tables.

The most important of these quirks is that IE does not allow you to modify the contents of a <td> tag. So, if you have a table data tag with an id of, say, row1col1 and you tried to do the following:



it will not work in IE. It works fine in any of the Mozilla family of browsers. To get around this quirk, you need to create your table so that any data that you might ever want to change dynamically is in some other container, such as a <div>, which in turn is inside the <td>.

So, if we have:



We can then to the following in JavaScript:



This will work for all browsers (except maybe Opera).

Also, outputing the table with the JavaScript method "document.write(s)" is fine if you are building the complete document dynamically, but if you are trying to add to or modify an existing document, that is one that is currently being viewed on the browser by the user, "document.write(s)" will overwrite the existing document or portions of it.

If you are adding the table to an existing document, then have a <div> on the document so that you can add the table by adding to the division's innerHTML.
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i use the javascript function to create a table is just because i'm using AJAX to make request from the server, and from the server script i pass back the value using 'out.println' and i want the value keep display out using table, and the value been pass in to the table will have hyperlink to another page. i donno how to put in the hyperlink to the insRow function to make the parameter value pass in have the hyperlink.

can provide the solution to me ???
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
plz help me, i want to place the hyperlink in the innerHTML is it can???
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at document.createElement("a") and appendChil like I already mentioned. SEARCH GOOGLE.

Eric
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thank you eric
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic