This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with runing query using 2 selectbox  RSS feed

 
sachin yadav
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
pax smith
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
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!