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



Home Answers Viewqa JSP-Servlet two linked combobox

Have Programming Question? Ask it here!
 
 
 


Nilay vora
two linked combobox
1 Answer(s)      3 years and 4 months ago
Posted in : JSP-Servlet


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


Advertisement
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, 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
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
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
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
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
to jsp combobox exmple
to jsp combobox exmple  to jsp combobox exmple
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>
HELP Generic linked list
HELP Generic linked list  How to create Generic linked list example program in Java
stack using linked list
stack using linked list  how to implement stack using linked list
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
Explain Linked List
Explain Linked List   hello, What is Linked List ?   hello, Linked List is one of the fundamental data structures. It consists of a sequence of nodes, each containing arbitrary data fields pointing to the next
Linked list implementation
Linked list implementation  How to create linkedlist by using array in java? and also How to manipulate
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
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
Core java linked list example
Core java linked list example  What is the real time example for linked 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
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
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
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
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
selection box linked with textarea
selection box linked with textarea    function get_val(tot_val1) { document.getElementById('TextBox1').value = tot_val1; alert(tot_val1); } <Table width="767" border="1" height="150
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.      
Simple Linked Lists
Java Notes: Simple Linked Lists This shows three programs. A simple singly-linked list. This shows the basics. A doubly-linked list. This is almost as simple as the singly-linked list, but makes some operations easier
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
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
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
combobox updation - Java Beginners
combobox updation  hi, i am using java swing to develop a gui.... It is required that on clicking a specific menu-the first combobox is populated using a vector, and then on clicking on a specific combobox item, the 2nd and 3rd
values in combobox - Java Beginners
values in combobox  how to fill values in combo box i.e. select tag in html using javascript?   Hi Friend, Try the following code: ComboBox var arr = new Array(); arr[0] = new Array("-select-"); arr[1
ComboBox ItemRenderer in DataGrid
ComboBox ItemRenderer in DataGrid  Hi..... How can I create custom combo box itemtenderer in the flex datagrid? please give me an example...; <mx:ComboBox > <mx:dataProvider>
Combobox program - Java Beginners
Combobox program  import javax.swing.*; import java.awt.*; public class SwingFrame1 { public static void main(String[] args) throws Exception... in combobox a new text box have to open beside that combo box..  Hi
linked list example problem - Java Beginners
linked list example problem  Q: Create your own linked list (do... two operations If you are using jdk1.4 or before..., elem1, elem2, ?, elemN] Test your linked list in a main method which
linked list example problem - Java Beginners
linked list example problem  Q: Create your own linked list (do... two operations If you are using jdk1.4 or before..., elem1, elem2, ?, elemN] Test your linked list in a main method which
linked list in java - Java Beginners
linked list in java  Hi, how to implement linked list in java using arrays please explain with the help of source code?  Hi import... information. http://www.roseindia.net/java/beginners/linked-list-demo.shtml
linked lists implementation - Java Beginners
linked lists implementation   1. Assume a programmer wanted to change the ADT of a list by adding the method: public boolean RemoveFirstLast..., there are no preconditions. Write the code for the method for a linked implementation (without tail
 

 

 

DMCA.com