Passing an selected option to another jsp page

Discussion in 'JSP' started by padmaharika, Mar 19, 2010.

  1. padmaharika

    padmaharika New Member

    Joined:
    Mar 19, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello sir

    I have created a dynamic dropdown box containing a list of states ,when i click a particular state it populates corresponding list of cities in another dropdown box.

    Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <script type="text/javascript">
    function setOptions(chosen) {
    var selbox = document.myform.opttwo;
     
    selbox.options.length = 0;
    if (chosen == " ") {
      selbox.options[selbox.options.length] = new Option('Please select one of the options
    above first',' ');
     
    }
    if (chosen == "1") {
      selbox.options[selbox.options.length] = new Option('hyderabad','hyd');
      selbox.options[selbox.options.length] = new Option('Secunderabad','sec');
    }
    }
    </script>
    </head>
    <body>
    <form name="myform"><div align="center">
    STATE: <select name="optone" size="1"
    onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
    <option value=" " selected="selected"> </option>
    <option value="1">Andhra Pradesh</option>
    <option value="2">Second Choice</option>
    <option value="3">Third Choice</option>
    </select><br /> <br />
    CITY: <select name="opttwo" size="1">
    <option value=" " selected="selected">Please select one of the options above first</option>
    </select>
    <input type="button" name="go" value="Click"
    onClick="window.open('profile.jsp','mywindow','width=500,height=350,toolbar=no,resizable=yes,menubar=yes')">
    </div></form>
    </body>
    </html>
    Till here it working perfectly ,but when i go to profile.jsp page i want to display the name of the State and city i have selected.So please can u help me in teling how to pass the parameters to drop down box to another page .
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice