• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

problem with runing query using 2 selectbox

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i have a problem. i had a form with 2 <select>boxes. named as--->

-------------------code---------------------
<select name="class"><option>------</option>
</select>

<select name="section"><option>------</option>
</select>

-----------------------------------------

i have two tables. i have to select a class name from first select box and then a query must fired which will check how many sections for that class exists in the table, for ex. if for class "1" we have section "a" and "b" then in the next selection box only 2 options as "a" and "b" must appear, if there are 3 section then "a","b","c" must appear.

i wana code this in JSP. how shud i do??

thanx n regards,

sachin.
 
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search this forum and the HTML forum for previous discussions on this very topic. It's been discussed dozens of times.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi


You can do this by two ways

1. get all the classes and their corresponding section in the jsp variables and then by selectbox onChange event you can populate the section combo box with desired value with the help of Jsp

2. When user change the value of class combo box it will fire the onchange javascript event. By this event get the value from database by sending the query to the database. but then your severside come in the picture
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by pax smith:

1. get all the classes and their corresponding section in the jsp variables and then by selectbox onChange event you can populate the section combo box with desired value with the help of Jsp



No, this cannot work. The oncahnge event will have no access to any of the scoped variables that were placed on the request.


2. When user change the value of class combo box it will fire the onchange javascript event. By this event get the value from database by sending the query to the database. but then your severside come in the picture



Either the page can be refreshed using a round-trip to the server, or Ajax could be used to fetch the updated data. In fact, this very problem is usually the text-book example for Ajax technology.
 
We're being followed by intergalactic spies! Quick! Take this tiny ad!
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!