Passing values in a form using javascript to a JSP page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanmukhi
    New Member
    • Jan 2007
    • 58

    Passing values in a form using javascript to a JSP page

    hi all

    in jsp
    i created a combo box and i written a java script to select values from combo box.
    when i select a value from combo box it should go to the another jsp page
    for that i passed the selected value as a string along with the url in java script.
    like <a href=.......... ?<%=val%>
    then how can i get this value into another jsp page.

    please any body can help me.....
    its urgent for me
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by shanmukhi
    hi all

    in jsp
    i created a combo box and i written a java script to select values from combo box.
    when i select a value from combo box it should go to the another jsp page
    for that i passed the selected value as a string along with the url in java script.
    like <a href=.......... ?<%=val%>
    then how can i get this value into another jsp page.

    please any body can help me.....
    its urgent for me
    You can set the value in a hidden input and get it in the next JSP using request.getPara meter("inputNam e");
    It's cleaner that way as you can submit the form using the post method.

    Comment

    • shanmukhi
      New Member
      • Jan 2007
      • 58

      #3
      Originally posted by r035198x
      You can set the value in a hidden input and get it in the next JSP using request.getPara meter("inputNam e");
      It's cleaner that way as you can submit the form using the post method.

      where can i write that hidden input value
      can you please provide a simple code for it

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by shanmukhi
        where can i write that hidden input value
        can you please provide a simple code for it
        You need to put that on a form on the JSP that is submitting the page. Do you have a form on the page?

        Comment

        • shanmukhi
          New Member
          • Jan 2007
          • 58

          #5
          Originally posted by r035198x
          You need to put that on a form on the JSP that is submitting the page. Do you have a form on the page?

          sorry i didn't get you,
          i cant explain entire senariou now
          imagine one.jsp is there
          in that i written one combo, i took some values from data base into that combo
          for selection i written java script like ...two.jsp?<%=v alue%>
          i should pass these values to two.jsp
          there i want to disply those values as hyperlinks...
          how i get those values into two.jsp

          please help me

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by shanmukhi
            sorry i didn't get you,
            i cant explain entire senariou now
            imagine one.jsp is there
            in that i written one combo, i took some values from data base into that combo
            for selection i written java script like ...two.jsp?<%=v alue%>
            i should pass these values to two.jsp
            there i want to disply those values as hyperlinks...
            how i get those values into two.jsp

            please help me
            Ok. How are you going from JSP one to JSP2. Are you clicking a submit button on a form or are you using an href link?

            Comment

            • shanmukhi
              New Member
              • Jan 2007
              • 58

              #7
              Originally posted by r035198x
              Ok. How are you going from JSP one to JSP2. Are you clicking a submit button on a form or are you using an href link?

              i used only href

              Comment

              • shanmukhi
                New Member
                • Jan 2007
                • 58

                #8
                please provide a good solution for my problem.
                thank u

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by shanmukhi
                  i used only href
                  You can use something like
                  [HTML]

                  <FORM method="post" action="<%=jsp2 Path%>" name="formName" >

                  <a href="javascrip t:document.form s['formName'].submit()" ....

                  <INPUT type="hidden" name="value" value="<%=value %>">
                  </FORM>
                  [/HTML]

                  Comment

                  • shanmukhi
                    New Member
                    • Jan 2007
                    • 58

                    #10
                    thank u very much for your reply...
                    but this code was not worked for me...

                    some how i got it...

                    but i got another problem

                    how can get a selected hyper link value into java script function
                    for eg:
                    in my jsp page
                    [CODE]
                    out.println("<a href='javascrip t:subwindow()'> "+customer+ "</a>");
                    [CODE]
                    what i can write in subwindow() function to extract link value
                    please help me

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Originally posted by shanmukhi
                      thank u very much for your reply...
                      but this code was not worked for me...

                      some how i got it...

                      but i got another problem

                      how can get a selected hyper link value into java script function
                      for eg:
                      in my jsp page
                      [CODE]
                      out.println("<a href='javascrip t:subwindow()'> "+customer+ "</a>");
                      [CODE]
                      what i can write in subwindow() function to extract link value
                      please help me
                      Let me move this to the javascript forum then. I think it belongs there now

                      Comment

                      • Ranga Sunilkumar Guturi
                        New Member
                        • Dec 2007
                        • 1

                        #12
                        Originally posted by shanmukhi
                        hi all

                        in jsp
                        i created a combo box and i written a java script to select values from combo box.
                        when i select a value from combo box it should go to the another jsp page
                        for that i passed the selected value as a string along with the url in java script.
                        like <a href=.......... ?<%=val%>
                        then how can i get this value into another jsp page.

                        please any body can help me.....
                        its urgent for me
                        go the jsp page , try to use the "value=<%=reque st.getParameter ("value")%>"
                        tqag ,
                        u may get the o/p
                        bye----sunil

                        Comment

                        Working...