This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Dynamic table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Dynamic table" Watch "Dynamic table" New topic
Author

Dynamic table

Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

I'm trying to make a dynamic table in javascript.



My problem is whenever I try to insert something into this table it directs me to another page while I want to do my transactions on the same page. Please help.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Are you by any chance calling that code from a submit button? If so, you need to return false so the page doesn't get submitted.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

document.write is a dinosaur and should no longer be used. It will create a new page if used after page load.

Rather, you want to use the DOM API to add elements to the DOM (which is painful), or jQuery (which is not).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Also, document.all is IE-specific. Bad idea to use it.
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

@Bear
I am actually using JQuery for few elements of the program. But I don't want to use it for the whole program.
What can I use instead of document.all. ..?? Which is compatible with at least Chrome and FireFox.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Yes, you can use jQuery for all of this very effectively.

In stead of document.all, use id values and jQuery to fetch elements by those ids.

If you are already using jQuery, there's no reason at all to be using antiquated techniques like document.write() or IE-specific nonsense like document.all.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Also, avoid embedding styles in elements with style. See how much repetition of code that's causing? Use CSS instead.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic table
 
Similar Threads
Problem with iframe in mozilla browser
Load Text file and display in table format.
how to use javascript to download the file automatically?
resultset is not working properly
Client side validation not working