Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions Populate listbox according to selection value from another selectbox
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vishal Dayaram Nemade
Populate listbox according to selection value from another selectbox
0 Answer(s)      a year and 5 months ago
Posted in : JavaScript Questions


hi...

I am developing my webproject in which i have 3 campus and each campus has different different courses. In registration form i want two select boxes one for campus and another for course. When i select campus i want to populate appropriate courses from database without page refresh. I have tried one solution but in that solution page will refreshed and then it will populate the course listbox from database but campus list box will removes selected value.. please help me....

my code...............

<%@ page language="java" %>
<%@ page import="java.sql.*" %>

<%!
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/jbgroup";;
String user = "root";
String pass = "admin";
ResultSet rs =null;
Statement st=null;
String query="";
String C1="C1";
int mid;
%>
<%
if(request.getParameter("mid")!=null){
mid=Integer.parseInt(request.getParameter("mid"));
}else {
mid=0;
}
Class.forName("com.mysql.jdbc.Driver") ;
conn = DriverManager.getConnection(url, user, pass);
st = conn.createStatement();
rs = st.executeQuery("select * from campus");
%>
<html>
<head>
<script type="text/javascript">

function selectCity(){
var mid=document.getElementById("countryId").selectedIndex;
window.location.replace("http://localhost:8080/RASS-JB1.2/listbox.jsp?mid="+mid);
}

</script>
</head>
<body>
<select id="countryId" name="countryId" onchange="selectCity(this)">
<option value="0">--Please Select--</option>
<% while(rs.next()){ %>
<option value="<%=rs.getString("CAMPUS_ID")%>"><%=rs.getString("CAMPUS_NAME")%></option>
<%}%>
</select>
<select>
<option value="0">--Please Select--</option>
<%
System.out.println(mid);
rs = st.executeQuery("select * from course where CAMPUS_ID='"+C1+""+mid+"'");
while(rs.next()){ %>
<option value='<%=rs.getString("COURSE_ID")%>'><%=rs.getString("COURSE_NAME")%></option>

<%}%>
</select>

</body>
</html>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Populate listbox according to selection value from another selectbox
Populate listbox according to selection value from another selectbox  ... listbox from database but campus list box will removes selected value.. please help... for campus and another for course. When i select campus i want to populate
Populate value into HTML page
Populate value into HTML page  Hi, How to populate values from one html page table to another html page..? Thanks
Advertisements
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.  I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid
how to retrieve the id value itself from the access database to drop down listbox in jsp
how to retrieve the id value itself from the access database to drop down listbox in jsp  how to retrieves the id which is an int datatype, from...   <%@page import="java.sql.*"%> <select> <option value
how to display data from database according to entered value in search field
how to display data from database according to entered value in search...("SELECT M.MEMBER_ID, M.FNAME,M.LNAME,M.AGE,B.HEIGHT,B.WEIGHT, B.BMI_VALUE FROM...;/b></td> <td>: <input type="text" name="bmi_value" id="BMI
Populate values from html to another html
Populate values from html to another html In this tutorial, you will learn how to send values from one html page to another. Here, we have create a html... on another html page. page1.html: <html> <form type=get action="
get the value from another class - Java Beginners
get the value from another class  Hello to all, I have stupid question. I have main.java and ConfigXML.java(read my config xml file). Code from...)).getNodeValue().trim(); from my ConfigXML.java in main.java. Sorry for my bad
change color according to the database value
change color according to the database value  any one know how to get values from database ( 1 or 0 ) and according to that change the color ( red or green) of given list
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>">...);%> since url print a common.jsp?param=Arts but attr return a null value
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>">...);%> since url print a common.jsp?param=Arts but attr return a null value
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  hello I m doing one project where I m retriving the data from databse in JTextField... button all the details of an item of JTextField will be displayed in another
to enter into a particular page only if the username,password and listbox value mtches
to enter into a particular page only if the username,password and listbox value... in to his page only if the username, password and the listbox value(user type... in the database. here i have a problem in checking the listbox value
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  Hello... to retrive the new records from database using the the value of JForm1... the records from database using up and down keys of keyboard? And also I wanted
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... to populate the first one, and then how to send the data off to a servlet and preform... to the client using ajax, and then populate the combo box, I must'nt reload
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
Get JTextField value from another class
Get JTextField value from another class   ... value from other class. For this, we have created two classes ClassA.java and ClassB.java. In ClassA, we have defined a textbox 'text1' that will get the value from
passing textbox value from one page to another page using html n javascript
passing textbox value from one page to another page using html n javascript  on button onclick event pass text box value and i want to pass value...;/td> </tr> <tr> <td colspan=2><input type=submit value
How to create textbox on combo value selection using javacsript in jsp?
How to create textbox on combo value selection using javacsript in jsp?  dynamically create textbox on combo value selection. when select multiple values then create multiple textboxes
selectbox - Framework
selectbox  Hello Roseindia, I want a favour from you..currently in my project i am using struts2.Now i want dyanmic database values add to select box in struts2 .....I don't want use scriptlets in jsp..give me ur valuable
jsp listbox - Java Beginners
jsp listbox  thanks for your earlier post. I have one list box filled from the datebase. i want my second listbox to be filled from the database based on the selection of first list box. without refreshing my jsp page
how to know which jList is selected and according to that fetch the value
is selected so that i get the value of employee_id from the correct jList (i.e which...how to know which jList is selected and according to that fetch the value ... , jList4) in 4 different tabs in frame. Each List has the value of employee_id
Values to listbox
Values to listbox  I have two textboxes by the name street and city.I have an add button and a name listbox. When I enter street and city and press the add button ,all the names of the people residing there are listed in listbox
my table should be reseted to new value upon the selection of the combo box..
my table should be reseted to new value upon the selection of the combo box...(true); initComponents(); try { rs= st.executeQuery("SELECT cname FROM pur...); sc1.setBounds(20, 160, 620, 380); } /** * This method is called from within
second selectbox of dynamic
second selectbox of dynamic  hello friends i hava a code like... values but i can't location values of city from database.thanks in advance..."> <input type="hidden" value="Leads" name="moduleName" /> <
How to obtain the selected data item from a list box when listbox contains objects wrapped under Arraylist?
How to obtain the selected data item from a list box when listbox contains... and a text box. I am sending an Array List object from a servlet to this jsp page. The listbox gets populated by the data contained in the arraylist. Now, I
checkbox with dropdown listbox in jsp
checkbox with dropdown listbox in jsp  i loaded the the data into the drop down listbox in jsp from access database.now i have to add a check box,if it checked means dropdownlist box carryout the data's,else it should
populate dropdown box
populate dropdown box  hi, Is there any ways in which i can populate my dropdown menu with values from 1 to n (n = the value stored in database)using java script or jsp, either is fine? Ex: If value corresponding to selected
Use varibles from another class
Use varibles from another class  **I have two classes. class 1:** public class askfigures extends JFrame { method from class1: public void... in another class. another class: public class Askvalues extends JFrame
Show a hidden frame previously from another from
Show a hidden frame previously from another from  How can i show a hidden frame previously by this code: jframe_name.hide(); and make it visible from another frame i'm waiting for the answer, and i'll be thankfull
Selection based on other selection in jsp
Selection based on other selection in jsp  I am trying to create... category there are products which are taken from a ms access table using a java.... I want to populate the field on product_name based on the category name
Selection Sort in Java
Selection sort in Java is used to sort the unsorted values in an array. In selection sorting algorithm, the minimum value in an array is swapped to the very first position in that array. In the next step the first value of array
 

 

 

DMCA.com