Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Delete respective row on clicking hyperlink using ajax and jquery  RSS feed

 
loki reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an HTML table with rows fetched from a session displayed in that table. I want the user to be able to delete a row by clicking on a delete hyperlink or button besides each row. How do I invoke a JSP function on the page, when the user clicks on each of those delete hyperlinks or button, so that I can delete that attribute from the session? What exactly should the or <button> tag have to call the Ajax and JQuery function?
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
loki reddy wrote:How do I invoke a JSP function on the page, when the user clicks on each of those delete hyperlinks or button, so that I can delete that attribute from the session?

It doesn't work like that. You don't invoke a JSP function on the page. JSP runs on the server and sends HTML to the user. At that point, the JSP is done. Kapput. No more.

You need to use JavaScript (jQuery is a great option and highly recommended) to catch the click event on the client side and then delete the corresponding row.

Try it simple first. Make a HTML page with a single row and write the JS code to delete that row. Post your code here and we'll help you along.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the The Ranch!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article to understand how JSP works and why you cannot call a "JSP function" on an event.
 
loki reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you @Kevin
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!