• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

javascript/jsp

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is it possible to get a javascript onClick() event to fire a sql query from my jsp page?
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Peter,
First I would say why you want to use JavaScript, why not jsp at both pages.
Okay, here is your solution........
HTML file using java script.

JSP file for firing SQL query.

This is just a sample code.You can modify it according to your requirment.
------------------
Regards
Gurpreet Sachdeva
For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: http://www.go4java.lookscool.com
[This message has been edited by Gurpreet Sachdeva (edited October 26, 2001).]
 
Peter Guillebaud
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gurpreet,
What I am trying to do is have one html select box populated as a result of a choice from a previous select box. I want to avoid having submit buttons but to use the onChange() method of the select box. What needs to happen is when the user chooses a value from the first box, the onChange() event on the client side somehow fires a sql query which populates the second box according to the choice in the first. Any ideas welcome!
TIA
[This message has been edited by Peter Guillebaud (edited October 29, 2001).]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, just remember that javascript is 100% client-side, and JSP code is 100% server-side.

There is really no way to get JSP code to run, and return to the 'same' page on the client side. You'll need a re-load of some sort. You *can* use javascript to submit the page to your server-side code, be it a JSP (and of course, you can submit the page to itself) or servlet. The server-side will know which value in the first select box has been selected, and when it is finished, it will re-display with both select boxes full of values.
 
Peter Guillebaud
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Mike, I used javascript to resubmit the jsp page to itself when the onchange() event was fired in the select box, and then jsp to do the sql query. Thanks for your help!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic