combobox

combobox

i have three tables in database country,state and city ...when i selected country ten only state show of that country similarly city depends on state i have implmnt dis code and it work propely bt problem is the field which inserted a value before country become erase \when selected country...plz help me sir

<%@page import="java.sql.*" %>
<html>
<head>
<title>New User Registration</title>
</head>
<body bgcolor="#CCFFFF">
<CENTER>
<H1> <u>EDUCATIONAL DATABASE SYSTEM</u> </H1>
</CENTER>
<a href="login.html">Home Page</a>

<%
String strcountrycode = "0";
String strstatecode = "0";
String strcitycode = "-1";

String strstatename = "";
String strcountryname = "";
String strcityname = "";


//checking the state code
if (request.getParameter("param1") != null){
strcountrycode=request.getParameter("param1").trim();
}

if (request.getParameter("param2") != null){
strstatecode=request.getParameter("param2").trim();
}

if (request.getParameter("param3") != null){
strcitycode=request.getParameter("param3").trim();
}%>

<script language="JavaScript" type="text/JavaScript">


//-->
//function for changing the url
function ChangeURL1(FileName,param1){
location.href=FileName + ".jsp?param1=" + param1;
}
function ChangeURL2(FileName,param1,param2){
location.href=FileName + ".jsp?param1=" + param1 + "&param2=" + param2;
}

function ChangeURL3(FileName,param1,param2,param3){
location.href=FileName + ".jsp?param1=" + param1 + "&param2=" + param2 + "&param3=" + param3;
}


  function validate()
  {
  if( document.kk.email.value=="")
  {
  alert("Email cannot be blank");
  return;

  }

  if( document.kk.name.value=="")
  {
  alert(" Name cannot be blank");
  return;

  }
  if( document.kk.phone.value=="")
  {
  alert("Phone Number cannot be blank");
  return;
  }
   if( document.kk.sta.value=="select state")
  {
  alert("You must select a state");
return;
  }


  if( document.kk.address.value=="")
  {
  alert("Address cannot be blank");
  return;
  }



  if( document.kk.pinCode.value=="")
  {
  alert("PinCode cannot be blank");
 return;
  }


  }

 </script>
<form name="kk" method="POST" action="signup.jsp">
           <%
         Connection conn=null;
    try
    {
            ResultSet rs,rm=null;
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        conn =DriverManager.getConnection("jdbc:odbc:neha");
                PreparedStatement stat,yu;%>


     <p align="center">
  <b><font size="5"> New User Registration</font></b>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </p>

  <div align="left">
    <table border="0" width="100%">
      <tr>
        <td width="23%"><b>Email *:</b></td>
        <td width="77%">
            <b>
      <input type="text" name="email" size="20" tabindex="1">
            </b>
        </td>
      </tr>

      <tr>
        <td width="23%">
            <b>
             Name*:</b></td>
        <td width="77%">
            <b><input type="text" name="name" size="20" tabindex="4">
            </b>
        </td>
      </tr>
      <tr>
        <td width="23%" height="25"><b>Phone Number*:</b></td>
        <td width="77%" height="25"><b><input type="text" name="phone" size="20" tabindex="13"> </b> </td>
      </tr>

      <tr>
        <td width="23%" height="25"><b>Country*:</b></td>
        <td width="77%" height="25">
          <select name="count" class="Textbox" onChange="ChangeURL1('userentry',document.kk.count.options[document.kk.count.selectedIndex].value);">
           <option value=''>select country</option>
              <%
                stat=conn.prepareStatement("SELECT country,countryID FROM mast_country ");

        rs = stat.executeQuery();
        while(rs.next())
        {

            String str1,str2;
                        str2=rs.getString("countryID");
            str1=rs.getString("country");
                    if(strcountrycode.equals(str2)) {
                      strcountrycode=str2;
                      strcountryname=str1;
                    %>
                    <option value="<%out.println(str2);%>" selected><% out.println(str1); %>
                        </option>
                        <%
                    }else{%>

                    <option value="<%out.println(str2);%>"><% out.println(str1); %>
                        <%

                    }
        }if(rs!=null){
                    rs.close();
                    rs=null;
                }

              %>
            </select>
</tr><tr>
        <td width="23%" height="25"><b>state*:</b></td>
        <td width="77%" height="25"><b>

<select name="sta" class="Textbox" onChange="ChangeURL2('userentry',document.kk.count.options[document.kk.count.selectedIndex].value,document.kk.sta.options[document.kk.sta.selectedIndex].value);">
            <option value=''>select state</option>
                 <%
                 yu= conn.prepareStatement("SELECT state,stateID FROM mast_state where countryID="+strcountrycode+" ");
                 rs = yu.executeQuery();
                  while(rs.next())
        {
            String str3,str4;
            str3=rs.getString("state");
                        str4=rs.getString("stateID");
                 if(strstatecode.equals(str4)) {
                      strstatecode=str4;
                      strstatename=str3;
                  %>
                  <option value="<%out.println(str4);%> " selected >"<%out.println(str3);%>"</option>
                 <%
                 }
                  else{%>

                  <option value="<%out.println(str4);%>"><% out.println(str3); %></option>

                  <%}


        }if(rs!=null){
                    rs.close();
                    rs=null;
                }

%>
</select></b></td>

      </tr>
      <tr>
        <td width="23%" height="25"><b>City*:</b></td>
        <td width="77%" height="25"><b>
        <select name="cty" class="Textbox" onChange="ChangeURL3('userentry',document.kk.count.options[document.kk.count.selectedIndex].value,document.kk.sta.options[document.kk.sta.selectedIndex].value,document.kk.cty.options[document.kk.cty.selectedIndex].value);">
            <option value=''>select city</option>
                 <%
                 yu= conn.prepareStatement("SELECT city,cityID FROM mast_city where stateID="+strstatecode+" ");
                 rs = yu.executeQuery();
                  while(rs.next())
        {
            String str5,str6;
            str6=rs.getString("city");
                        str5=rs.getString("cityID");
                 if(strcitycode.equals(str5)) {
                      strstatecode=str5;
                      strstatename=str6;
                  %>
<option value="<%out.println(str5);%>" selected>"<%out.println(str6);%>"</option>
                 <%
                 }
                  else{%>

                  <option value="<%out.println(str5);%>"><% out.println(str6); %></option>

                  <%}


        }if(rs!=null){
                    rs.close();
                    rs=null;
                }

%></select>

        </b> </td>
      </tr>
       <tr>
        <td width="23%" height="25"><b>Place*:&nbsp;</b></td>
        <td width="77%" height="25"><b><input type="text" name="place" size="20" tabindex="11"> </b> </td>
      </tr>
      <tr>
        <td width="23%" height="25"><b>Pin Code*:&nbsp;</b></td>
        <td width="77%" height="25"><b><input type="text" name="pinCode" size="20" tabindex="11"> </b> </td>
      </tr>
        <tr>
        <td width="23%" height="25"><b>Address*:&nbsp;&nbsp;</b></td>
        <td width="77%" height="25"><b><input type="text" name="address" size="43" tabindex="7"> </b> </td>
      </tr>


      <tr>
        <td width="23%" height="1"></td>
        <td width="77%" height="1"> </td>
      </tr>
      <tr>
        <td width="23%" height="21"></td>
        <td width="77%" height="21">
   <b>
   <input type="submit" value="Submit" name="B1" onclick = "validate();" tabindex="13">
   </b>
 </td>
      </tr>
    </table>
  </div>


            <%
        }
    catch(Exception E)
    {
        System.out.println("error");
    }%>

</form>


</body>

</HTML>
View Answers









Related Tutorials/Questions & Answers:
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
Advertisements
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
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
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
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
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
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
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
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.....ADS...; <mx:ComboBox > <mx
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
Combobox jsp from 0 to 10
Combobox jsp from 0 to 10  Hi guys please help me to write a very easy program using jsp to display value in combobox from 0 to 10. How to write the for loop? Please help.Thank!!!   <html> <select> <
FLEX 3 Combobox - Development process
and just started tinkering with Adobe Flex. I have downloaded your combobox... a combobox - once selected - it will show the airport code into a text field. Example: ComboBox Chicago,Illinois Boise, Idaho Buffalo, New York Baltmore
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
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
How to Connect J ComboBox with Databse - Java Beginners
How to Connect J ComboBox with Databse  How to Connect J ComboBox with Databse  Hi Friend, Do you want to get JComboBox values from database?Please clarify this. Thanks
Combobox in HTML
Combobox in HTML is used to display a drop-down list of some options from which one can be selected. <select> tag is supported in all the web browsers... the options in the list.ADS_TO_REPLACE_1 Here is how to make a simple Combobox
Example of struts2.2.1 combobox tag.
Example of struts2.2.1 combobox tag. In this tutorial, you will see the implementation of struts2.2.1 combobox tag. The combobox is basically an HTML INPUT... it in directly in the text field.  Directory structure of combobox tag
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
java code using combobox,radiobutton,checkbox
java code using combobox,radiobutton,checkbox  hi, send me java code for entering student details into ms access database, the code should includes combo box,radiobutton and checkboxes pl send as early as possible
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Displaying data from combobox on the web page
Displaying data from combobox on the web page  Sir, I have to make a project in which a data from the database is to be displayed in combo box and depending on the choice made in combo box the data pertaining to it from
Java ComboBox in JOptionPane
Java ComboBox in JOptionPane In this section, you will learn how to create combo box in JOptionPane dialog box. We have created a button to perform an action.On clicking the button, you will get the dialog box with combo box in it. 
Jdbc Login Page Validation using Combobox
want to login by validating with combobox....The link which you send its.......please help me i dont know how to validate the combobox for diffrent cities please help me by validating with combobox.... <form action
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
Non-edit Combobox with auto fill - Swing AWT
Non-edit Combobox with auto fill  Hi, I have a non-edit JCombobox with auto fill capability. Auto fill is working only for the first character typed by the user. For example, ["Callisto", "Charls", "chim"] are the data
Java swing: get selected value from combobox
Java swing: get selected value from combobox In this tutorial, you will learn how to get selected value from combobox. The combobox provides the list... of programming languages to the combobox using addItem() of JComboBox class. We have
Connect J ComboBox with Databse - Java Beginners
Connect J ComboBox with Databse  Hello Sir I want To Connect MS Access Database with JComboBox , when I Select any Item from Jcombobox Related Records will Display in to JTextBox eg when i select MBA then fees ,Duration
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE ... createuser.jsp. There am loading this Rolename into combobox. My question is how to get Roleid in textbox when i select Role_name from combobox in a same
Passing values in ComboBox from XML file
Passing values in ComboBox from XML file In this tutorial we are going to know how we can pass a values in ComboBox by using XML.  This example... the data from the XML file and insert it into the ComboBox. To make a program over
pbml in inserting selected item from combobox into mysql - XML
pbml in inserting selected item from combobox into mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
Flex ComboBox Component
Adobe Flex Combo Box Component: The ComboBox component of Flex is similar to the select option of HTML code. This component also has editable mode, in which a user can type on the top of the list. We use this component inside
How to declare a Combobox without using a string in its declaration?
How to declare a Combobox without using a string in its declaration?  What i mean to ask is how can i declare a combobox first and initialise the values later? For example JComboBox x= new JComboBox(); ... String s={"Alpha
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
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl

Ads