two linked combobox

two linked combobox

give jsp example of two combo box when i select state in one combobox in second combo box cities will display according to state which i select

View Answers

March 29, 2011 at 4:50 PM

1)state.jsp:

 <%@page import="java.sql.*"%>
 <html>
      <head>  
      <script language="javascript" type="text/javascript">  
      var xmlHttp  
      var xmlHttp

      function showCity(str){
      if (typeof XMLHttpRequest != "undefined"){
        xmlHttp= new XMLHttpRequest();
        }
      else if (window.ActiveXObject){
        xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
        }
      if (xmlHttp==null){
      alert("Browser does not support XMLHTTP Request")
      return;
      } 
      var url="city.jsp";
      url +="?count=" +str;
      xmlHttp.onreadystatechange = stateChange1;
      xmlHttp.open("GET", url, true);
      xmlHttp.send(null);
      }
      function stateChange1(){   
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
      document.getElementById("city").innerHTML=xmlHttp.responseText   
      }   
      }
      </script>  
      </head>  
      <body>  
      <select name='state' onchange="showCity(this.value)">  
       <option value="none">Select</option>  
    <%
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from state");
 while(rs.next()){
     %>
      <option value="<%=rs.getString("stateid")%>"><%=rs.getString("state")%></option>  
      <%
 }
     %>
      </select>  
      <br>  
       <div id='city'>  
      <select name='city' >  
      <option value='-1'></option>  
      </select>  
      </div>
      </body> 
      </html>

2)city.jsp:

<%@page import="java.sql.*"%>
<%
String state=request.getParameter("count");  
 String buffer="<select name='city'><option value='-1'>Select</option>";  
 try{
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from city where stateid='"+state+"' ");  
   while(rs.next()){
   buffer=buffer+"<option value='"+rs.getString(2)+"'>"+rs.getString(3)+"</option>";  
   }  
 buffer=buffer+"</select>";  
 response.getWriter().println(buffer); 
 }
 catch(Exception e){
     System.out.println(e);
 }
 %>









Related Tutorials/Questions & Answers:
two linked combobox
two linked combobox  give jsp example of two combo box when i select state in one combobox in second combo box cities will display according to state which i select
Concatenate two linked lists
Concatenate two linked lists  hello, How to concatenate two linked lists?   hii,ADS_TO_REPLACE_1 You can change null pointer of the first linked list to point the header of the second linked list
Advertisements
Multiplication of two polynomials using linked list in java
Multiplication of two polynomials using linked list in java  I am doing a program "Multiplication of two polynomials using linked list in java... for polynomial linked list import java.util.Scanner; class Node { public int
How to make addition of two combobox values using jsp and javascript?
addition of two combobox values using jsp and javascript  How to make addition of two combobox values using jsp and javascript?  <html> <h2>ComboBox</h2> <script language="javascript"> var arr
linked list
linked list  program for single linked list
Linked list
Linked list  what is difference btw linked list in datastructure and linked list in java
linked list
linked list  hi i have basal problem what is the linked list
linked list
linked list  Hi i have a problem with linked list ! how and where i can use linked list? please give me some example.   Please visit...://www.roseindia.net/java/beginners/linked-list-demo.shtml
linked list
linked list   how to add student and mark and number from file in linked list and print them also how to make search function plz can help me sooon
linked lists
linked lists  write a program to create a circular linked list...;(); list.add("One"); list.add("Two"); list.add("Three"); list.add("Four...("Two")); System.out.println(list.remove("One")); System.out.println(list.remove
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
to jsp combobox exmple
to jsp combobox exmple  to jsp combobox exmple
Linked List
Linked List  public class Computer{ private int computerNumber... in the following logical linked list represents Computer Number. 76(head) 98 54...? to ?66?. The segment should also display the new contents of the linked list
Flex Combobox
Flex Combobox  flex combobox with database as dataprovider   You can visit the following link for detailed tutorial on the topic. May this will be helpful to you. http://www.roseindia.net/flex/flex-combo-box.shtml
linked list
linked list   how to write a program using a linked list, that will prompt a user to enter 10 names and display them in reverse   import java.util.*; class LinkedListExample { public static void main(String[] args
linked list
linked list  Data Structures An English institute has a different... program to manage the registration details for the institute. 1. Use a linked list to manage the details of all registered students. a. Create your own linked list
Flex Combobox
Flex Combobox  flex combobox with database as dataprovider  ... backgroundColor = '#CCCCFC' width = '100%' height = '100%'> <mx:ComboBox...; <mx:ComboBox x = '200' color = 'green'> <mx:dataProvider>
combobox
combobox
combobox
combobox
combobox
Write a MoveFirst() for Circular Linked List
Write a MoveFirst() for Circular Linked List  write a MoveFirst(T elt... to the element before that one. so if i have " one two three four) and the moveFirst(two); it should read "two three four one
jsp combobox
jsp combobox  ihave three tables in database country,state and city..if i select one country throug combo box than other combobox show state only select country ...than city how i can implement through jsp   1
stack using linked list
stack using linked list  how to implement stack using linked list
HELP Generic linked list
HELP Generic linked list  How to create Generic linked list example program in Java
how to select second combobox value .
how to select second combobox value .  I requirement is , i have two combo box, i am selected first combo box value then automatically second combo box value show ,But this both combo box value i retrieves in database. please
Explain Linked List
Explain Linked List   hello, What is Linked List ?   hello,ADS_TO_REPLACE_1 Linked List is one of the fundamental data structures. It consists of a sequence of nodes, each containing arbitrary data fields pointing
Linked list implementation
Linked list implementation  How to create linkedlist by using array in java? and also How to manipulate
ComboBox in Flex4
ComboBox in Flex4: In Flex4 Combobox is called a spark Combobox control. DropDownListBase control is the base class of the combobox control. Combobox control works like a DropDownList control. When we click on the combobox control
editable combobox method selection
editable combobox method selection  how to make an editable combobox that shows nothing initially but as a key is pressed it pops up and selects an item starting with that letter, subsequent keys would keep sorting from the list
how to use an editable combobox
how to use an editable combobox   Hello Everyone!!!!!!!! I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item
fill combobox at runtime jsp
fill combobox at runtime jsp  i have 1 combobox in jsp which... another combobox below it, i want it to be filled on the basis of selected value of 1st combobox...plz help with code
Core java linked list example
Core java linked list example  What is the real time example for linked list
java linked list urgent!!!
java linked list urgent!!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
java linked list urgent !!!
java linked list urgent !!!  Q1. Generate 10 thousand random integers with values in the range between 1 to 100. Q2. Store each randomly generated number into a node and then attach the node to a linked list. The list must
Java Swing dynamic Combobox
Java Swing dynamic Combobox In this section, you will learn how to display the data in one combobox related to another combobox. For this, we have created two combo boxes. In the first combobox, we have added four items. When the user
Linked Lists in C
Linked Lists in C  Hi all, I have a project to be implemented in C.... The treatment is done in a linked list. The application works on the command line... in the linked list.If the file does not exist then create it . And an empty list
doubt in combobox in flex - XML
doubt in combobox in flex  hi, i have doudt in combobox in flex which is a combination of mxml and actioscript . In my project i has a combobox with 10 items when i select the particular item i has 2 display
Overview of Linked List
Linked List A linked list is a data structure which consists of data record...-defined. There are mainly three kinds of linked lists: Singly linked list Doubly linked list Circular linked list.      
combobox cannot be resolved in JavaFX
combobox cannot be resolved in JavaFX  I want to design one application with a combobox containing items. and while selecting i want to give user autocomplete suggestion. but while doing this combobox is not getting resolved. i
ModuleNotFoundError: No module named 'linked_list'
ModuleNotFoundError: No module named 'linked_list'  Hi, My Python... 'linked_list' How to remove the ModuleNotFoundError: No module named 'linked_list' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'linked-neurons'
ModuleNotFoundError: No module named 'linked-neurons'  Hi, My... named 'linked-neurons' How to remove the ModuleNotFoundError: No module named 'linked-neurons' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'linked-properties'
ModuleNotFoundError: No module named 'linked-properties'  Hi, My... named 'linked-properties' How to remove the ModuleNotFoundError: No module named 'linked-properties' error? Thanks   Hi, In your
about linked list
about linked list   hey can u help me soon ?? i want to add student,mark,and id from keyboard i want to calculte the number of students pass if his... in linked list   import java.util.*; class StudentData{ int id
Combobox application - Swing AWT
Combobox application  hi, i am facing a problem in updation of the comboboxes i m using in an application...for the first time the selectec item does is not returned and thus i am unable to pass it as an argument to another

Ads