Retriving value from dropdown list nad disply it in other page

Retriving value from dropdown list nad disply it in other page

Hello,

I have a dropdownbox on my webpage and a map which contains a marker, and that marker contains a button, on click of that button i need to get the name of the selected value from the dropdown list and dispaly it to on the next page.

i used request.getParameter("") but its not working its printing "null".

So could you please help me out with this!!

thanks, Pradeep

View Answers

January 13, 2011 at 12:44 PM

Hi Friend,

Try this:

1)combo.jsp:

<html>
<form method="post" action="selectedValue.jsp">
Select Programming Language:
<select name="lang">
<option value="C/C++">C/C++</option>
<option value="C#">C#</option>
<option value="Java">Java</option>
<option value="Perl">Perl</option>
<option value="Python">Python</option>
</select><br>
<input type="submit" value="Submit"><br>
</form>
</html>

2)selectedValue.jsp:

<%
String selectedValue=request.getParameter("lang");
out.println("Selected Value is: "+selectedValue);
%>

January 13, 2011 at 12:44 PM

Hi Friend,
Try this:

1)combo.jsp:

<html>

<form method="post" action="selectedValue.jsp">
Select Programming Language:
<select name="lang">
<option value="C/C++">C/C++</option>
<option value="C#">C#</option>
<option value="Java">Java</option>
<option value="Perl">Perl</option>
<option value="Python">Python</option>
</select><br>
<input type="submit" value="Submit"><br>
</form>

</html>

2)selectedValue.jsp:

&lt;%
String selectedValue=request.getParameter("lang");
out.println("Selected Value is: "+selectedValue);
%&gt;

January 13, 2011 at 2:07 PM

but my problem is i have the button on my marker and the dropdownlist is on the webpage so how to link both button and dropdownlist

can u please help me on this issue


January 14, 2011 at 3:21 PM

Hi Friend,

Post your code.

Thanks


January 17, 2011 at 11:45 AM

ok iam posting my code

This is my 1.jsp file

<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %>

        <%!
            int i=1;
            Connection connection = null;
            boolean foundResults = false;
            ResultSet set = null;
            Statement statement = null;
            String city;
            String ip;
            String sysname;
            String sess;

        %>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 

  <head> 

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 

    <title>Google Maps API Sample</title>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAPDUET0Qt7p2VcSk6JNU1sBSM5jMcmVqUpI7aqV44cW1cEECiThQYkcZUPRJn9vy_TWxWvuLoOfSFBw" type="text/javascript"></script>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q"></script>                                 

    <script type="text/javascript"> 

    var map; 

    var geocoder;

    var address=sel.options[sel.selectedIndex].value;
    document.write(address);

    //sess = address;
    //session.setAttribute("sess1",sess);

    function createMarker(point,html,what) 

    {

        var marker = new GMarker(point,{id:what, name:"foo", description:"baz"});

        GEvent.addListener(marker, "mouseover", function() {

        marker.openInfoWindowHtml(html);

        });

        return marker;

     }

    function initialize() 
    { 

        map = new GMap2(document.getElementById("map_canvas")); 

        map.addControl(new GLargeMapControl());

        map.addControl(new GScaleControl());

        map.setCenter(new GLatLng(79, 0, true), 8); 

        map.addControl(new GMenuMapTypeControl(true,false));

        var point1 = map.getCenter();

        var marker = createMarker(point1,'<img src="printers-for-wire-and-network-elements-marking-43844.jpg" width="100" height="100">',"this")

        map.addOverlay(marker);

        geocoder = new GClientGeocoder();                       

    }


    function addAddressToMap(response) { 

     map.clearOverlays(); 

     if (!response || response.Status.code != 200) { 

       alert("Sorry, we were unable to geocode that address");

     } else { 

       place = response.Placemark[0];

       point = new GLatLng(place.Point.coordinates[1], 

                           place.Point.coordinates[0]); 
        //var test = 'ajaykumar';
        //alert(test);
      var marker = createMarker(point,'<form action="/Details.jsp"><input type="image" name="b" value="click" src="printers-for-wire-and-network-elements-marking-43844.jpg" width="100" height="100"></form>',"this");

      map.addOverlay(marker); 
      marker.openInfoWindowHtml('<b>Coordinates:</b>' + place.Point.coordinates); 
     }

    }

    function showLocation(sel) 
    { 

     address = sel.options[sel.selectedIndex].value;
     geocoder.getLocations(address, addAddressToMap); 

    } 

    function findLocation(address)
    { 

     showLocation(); 

    }

    function find()
    { 

     window.open("/Details.jsp","winA","width=300,height=300,resizeable=no")

    }


 </script> 

  </head> 

  <body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;"> 


  <form name="f1" action="#" onsubmit="showLocation(); return false;">

  <p> 
        <TABLE ALIGN="CENTER">
        <b>Search cities:</b>


        <%
            try 
            {
                Class c = Class.forName("org.postgresql.Driver");
                //out.print(c);

                connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres","postgres", "password");

                statement = connection.createStatement();               

                set = statement.executeQuery("SELECT sno,city,ip,sysname FROM test");


        %>
            <select name="htmlcombo" onchange="showLocation(this)">
        <%
            while(set.next())
            {

        %>
            <option value=<%= set.getString(2)%>> <%= set.getString(2)%> </option>

        <%  } 

        %>
            </select>

            </TABLE>

        <%

            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        %>
      </p> 

    </form>


    <div id="map_canvas" style="width: 1250px; height: 740px"></div>
    <form>
    <%
    try{
        out.print(set.getString(2));
    %>

    <%
    }
    catch(Exception e)
    {}
    %>
    </form>

  </body>

I need the selected value in my 2.jsp file on clicking of the image on the marker.

2.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %>

        <%
            int i=1;
            Connection connection = null;
            boolean foundResults = false;
            ResultSet set = null;
            Statement statement = null;
            String city;
            String ip;
            String sysname;

            //String getCity=(String)session.getAttribute("sess1");
            //out.print(getCity);

            String val=request.getParameter("htmlcombo");
            out.print(val);



            //out.print(request.getQueryString());

            try 

            {
                Class.forName("org.postgresql.Driver");

                connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", 
                                           "postgres", "password");

                statement = connection.createStatement();               

                set = statement.executeQuery("SELECT sno,city,ip,sysname FROM test where city='"+val+"'");

                while(set.next())
                {
                    city=set.getString(2);
                    ip=set.getString(3);
                    sysname=set.getString(4);
                    out.print(city+"<br>");
                    out.print(ip+"<br>");
                    out.print(sysname+"<br>");
                    out.print("<br><br>");

                }
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        %>









Related Tutorials/Questions & Answers:
Retriving value from dropdown list nad disply it in other page
Retriving value from dropdown list nad disply it in other page  Hello, I have a dropdownbox on my webpage and a map which contains a marker... of the selected value from the dropdown list and dispaly it to on the next page. i
how to load value in dropdown list after selecting value from first dropdown list using javascript
how to load value in dropdown list after selecting value from first dropdown list using javascript  how to load value in dropdown list after selecting value from first dropdown list using javascript
Advertisements
help to select a value from the dropdown list
help to select a value from the dropdown list  I have a html file... from the drop down list created in a div and put it in the textbox kim... <input type="text" size="30" name="inputString" value="" id="inputString
how to use dropdown list in JSP and display value in same page
how to use dropdown list in JSP and display value in same page  I have a Dropdown list with some values say "A", "B" and "C" When the user selects one option the value must get displayed below it in the same page
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier problems somehow but now this time another problem arised when I want to pass the value from a link to a dropdown list. I want to set the dropdown list selected
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier problems somehow but now this time another problem arised when I want to pass the value from a link to a dropdown list. I want to set the dropdown list selected
getting values from dropdown list
getting values from dropdown list  I am having a dropdown list which has hardcoded values ( we need it hardcoded only and will not be populated from the database) My question is when i select a particular value it should be pass
Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP  as i said i want to create 3 drop dropdown list each depend on the other and get the options from
populating one dropdown box depending on the value of other using jsp
populating one dropdown box depending on the value of other using jsp ... on the value of other using the below table country name state and city name should load in dropdown box one after the other CREATE TABLE CITY_MASTER( CITYID BIGINT
3 dropdown list from the database using JSP
3 dropdown list from the database using JSP  Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
JSP Get Data Into Dropdown list From Database
JSP Get Data Into Dropdown list From Database In this section we will discuss about how to fetch data dynamically into the dropdown list in JSP... for fetching data from the database and set it into the dropdown list in JSP
How to automatically change the value of the textbox based on the dropdown list?
How to automatically change the value of the textbox based on the dropdown list?  I want to know how to automatically change the value of price and the quantity text boxes. Here is my code: <%@ page import="java.sql.
DropDown list
values into dropdown list. 1)country.jsp: <%@page import="java.sql.*"%>...DropDown list  how to get mysql database values into dropdown usign...;option value="none">Select</option> <% Class.forName
How to access Contacts from gmail using LDAP in JSP dropdown list
How to access Contacts from gmail using LDAP in JSP dropdown list  HI, I am creating a JSP page in which i have to make a dropdown box, and access gmail contacts in that drop downlist using LDAP. Can any one plz help me out
. Display JavaScript dropdown selected value
value from dropdown box? I am using javascript.   <html> <... you select any value from list, alert will display that. In var... document.getElementById("dropdown").value .you can show this value in alert or any other
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list ... dropdownlist in jsp page.If i select any value in that list(for eg-rollno),then it want to display all records from table specific to that rollno in that same
Not retriving the validations from validation.xml - Struts
Not retriving the validations from validation.xml  I have create the file called register.jsp    LoginID: Password: when i
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
How to invoke other java class by selecting from dropdown menu... a dropdown menu to choose type of report and then click on submit button.On clicking submit button should show the user various textfields on the same panel from
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
How to invoke other java class by selecting from dropdown menu... a dropdown menu to choose type of report and then click on submit button.On clicking submit button should show the user various textfields on the same panel from
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
How to invoke other java class by selecting from dropdown menu... a dropdown menu to choose type of report and then click on submit button.On clicking submit button should show the user various textfields on the same panel from
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp ... and department fields also.I have a create an jsp page in which there should 2 drop down list.In that first list is for department and the 2nd list for the names
dropdown list in jsp
dropdown list in jsp  hai, i have static dropdown list.. i want to get the selected value in string variable without jsp regards asha
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list  Thanks for your suggesstion.but Please provide me coding by using only one dropdownlist in javascript or jquery.Thanks in advance
loading value into combo box by selecting value from other combo box - JSP-Servlet
loading value into combo box by selecting value from other combo box  ... is that as i select state from state_combo_box,then the next combo box is dynamically... in same JSP page. please help me
Retrieval of Dropdown list
, the corresponding value of A1, list of name corresponding to A1 wil be displayed in another...Retrieval of Dropdown list  Hi frnds... Am having problem with the below code... I have retrieved data from the mysql database into dropdownlist
retriving image from database - JSP-Servlet
retriving image from database  how to retrive image from mysql database by using servlet programming  Hi Friend, Please visit the following link: http://www.roseindia.net/servlets/retreiveimage.shtml Thanks
struts dropdown list
struts dropdown list   In strtus how to set the dropdown list values from database ? I have a ArrayList object and set this object in dropdown jsp page using struts ? please send me jsp code... sample code: **Action
how can i send a mail to a particular user from a many user dropdown list in jsp
how can i send a mail to a particular user from a many user dropdown list in jsp  how can i a sent a user question to a particular person from a drop down list in jsp
How to pass the value from controller to jsp page ?
How to pass the value from controller to jsp page ?  HI I need to pass the value from controller to jsp. I use the way like this Controller request.setAttribute("msg", "Successfully Login"); In jsp ${msg} and then i
dropdown list in jsf
dropdown list in jsf  I want to add a list box to display the country name from the lists on all countries.When I select for e.g India then in the second list box it will display the states related to India only and the flow
jsp- database dependent dropdown list
jsp- database dependent dropdown list   i want 2 dropdown list 1- CLASS 2-SECTION both are should come from database. and if i select a class suppose class a the corresponding section dropdown list should retrieve the section
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list...=mysql_query("select * from age order by Age_Desc"); while($row_list=mysql_fetch
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list...=mysql_query("select * from age order by Age_Desc"); while($row_list=mysql_fetch
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list...=mysql_query("select * from age order by Age_Desc"); while($row_list=mysql_fetch
Retriving data from MYSQL without line break using java
Retriving data from MYSQL without line break using java  get data without line breaking from mysql table (i.e data stored as mediumtext )using java
How to change the dropdown values based on other dropdown in itext pdf or in any other?
How to change the dropdown values based on other dropdown in itext pdf or in any other?  How to change the drop down values based on another drop down? For eg: If we select one county, that related states only come, if we select
dropdown list and text fields in php
dropdown list and text fields in php  How could I use php to populate text fields by selecting a name of a business from dropdown list? Those text... number, description, and opening times from a mysql database. If you can, post
passing text value from pop up to parent page
passing text value from pop up to parent page  i want to pass value of a textbox of one pop up window to its parent page(html). that parent page contain a table. And i want to pass that text value to one cell in table of parent
unable to get value returned from javascript variable in page
jsp page..what i want is to store the value returned from the js function... the value of the radio button from fisrt page to be stored in a variable so...unable to get value returned from javascript variable in page  Hi, I
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I... i want is when the value in booking status is "booked" then the pictures shown as seats should be displayed red. when the value in booking status
getting and storing dropdown list in database in jsp
getting and storing dropdown list in database in jsp  i have a drop down list to select book from database. i'm able to retrieve dropdown list from database. but unable to store the selected value in database table. please help
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
Dropdown Checkbox list
Dropdown Checkbox list This tutorial explains how to create jquery Dropdown... jquery Dropdown Checkbox list. The application directory structure should look like... dropdown list as checkbox  (adsbygoogle = window.adsbygoogle
Get JTextField value from another class
value from other class. For this, we have created two classes ClassA.java and ClassB.java. In ClassA, we have defined a textbox 'text1' that will get the value from... Get JTextField value from another class   
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
Calling Servlet to build a List of data from database and show this on the JSP page in table
Calling Servlet to build a List of data from database and show this on the JSP... to retrieve all the data from database and then add the data into list. The list is then added to the request object and sen to JSP page. On the JSP page this value
passing textbox value from one page to another page using html n javascript
passing textbox value from one page to another page using html n javascript  on button onclick event pass text box value and i want to pass value... on the othe (next/prevoious)page please help me   1)page1.html: <html>
Dropdown code to retrieve result from oracle database
Dropdown code to retrieve result from oracle database  Hi Friends, I... that will retrieve values from the database into dropdown. As the user choose any option from the dropdown, corresponding values will get displayed in the textboxes
How to add a DropDown List in Flex DataGrid
How to add a DropDown List in Flex DataGrid  hi I am trying to add a DropDownList in a DataGrid table. After the user selects one of the items from... select from one of the choices in the list. That's my reason for trying to add
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct... in dropdown box.... so when i login i all the three username,password and dropdown box value(i.e)company name should match.... pls provide code.... thanx   1

Ads