combobox

Ads
 

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

Ads









Related Tutorials/Questions & Answers:
to jsp combobox exmple
to jsp combobox exmple  to jsp combobox exmple
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
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
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
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 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> <
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
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. Here is how to make a simple Combobox in HTML: <html>
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
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
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
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
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
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

Ads