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

Dynamic table

 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, document.all is IE-specific. Bad idea to use it.
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, avoid embedding styles in elements with style. See how much repetition of code that's causing? Use CSS instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic