0

Hi i've the below jsp created.

    <%@page contentType="text/html" pageEncoding="UTF-8"%>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <script type="text/javascript">

    function show(x,y)
    {
        document.getElementById(x).style.display='block';
        document.getElementById(y).style.display='none';
    }
function hide(x)
    {
        document.getElementById(x).style.display='none';
        document.getElementById(y).style.display='block';
    }


function myKeyPress(e,x,y){
    var keynum;
    if(window.event){ // IE
        keynum = e.keyCode;
    }else
    if(e.which){ // Netscape/Firefox/Opera
        keynum = e.which;
    }
    //alert(String.fromCharCode(keynum));
    //alert(keynum);
    if (keynum == 13) {
        //document.getElementById("yourForm").submit();
        var m=document.getElementById(x).value;
        alert(m);
        hide(x,y);
        //document.form1.action="abc.jsp?val="+x;
        //document.form1.submit();
    }
}
    </script>

</head>
<body>
    <form name="form1" method="post" action="abc.jsp">
      <table width="722">
        <tr>
          <td width="431" height="190">
          <table width="439" >
            <tr>
              <td width="129">PARTS Updated</td>
              <td width="108"><p>
                <select name="PARTS_Updated" id="PARTS_Updated" >
                  <option value=""></option>
                  <option value="N/A">N/A</option>
                </select>
              </p></td>
              <td width="186"><label for="PARTS_Updated"></label></td>
            </tr>
            <tr>
              <td>TSI OK&#13;</td>
              <td><p>
                      <input type="radio" name="radio" id="TSI_N/A" value="TSI_N/A" onClick="hide('TSI_Query_Box')">
                N/A
              </p>
              <p>
<input type="radio" name="radio" id="TSI_Query" value="TSI_Query" onClick="show('TSI_Query_Box','SI_Query_Box')">              TSI Query</p></td>
              <td><label for="TSI_Query_Box"></label>
                  <textarea name="TSI_Query_Box" id="TSI_Query_Box" cols="15" rows="5" style="display:none"  onkeypress="return myKeyPress(event,'TSI_Query_Box','SI_Query_Box')"></textarea></td>

            </tr>
            <tr>
              <td height="65">Special Ins OK&#13;</td>
              <td><p>
                <input type="radio" name="radio" id="SI_N/A" value="TSI_OK" onClick="hide('SI_Query_Box')">
                N/A
              </p>
                <p>
<input type="radio" name="radio" id="SI_Query" value="SI_Query" onClick="show('SI_Query_Box','TSI_Query_Box')"> SI Query</p></td>
              <td><label for="SI_Query_Box"></label>
                  <textarea name="SI_Query_Box" id="SI_Query_Box" cols="15" rows="5" style="display:none" onkeypress="return myKeyPress(event,'SI_Query_Box','TSI_Query_Box')""></textarea></td>
            </tr>
          </table></td>
          <td width="279">
              <table width="279" align="center">
            <tr>
              <td width="87"><p>Shipment ID&#13;</p></td>
              <td width="97"><label for="Ship_ID" id="Ship_IDl"></label>
              <input type="text" name="Ship_ID" id="Ship_ID"></td>
            </tr>
          </table></td>
        </tr>
      </table>
      <p>&nbsp;</p>
      <table width="721" border="1">
        <tr>
          <td width="374" align="center">
              <input type="submit" name="Send for CT Review (SCTR)" id="Send for CT Review (SCTR)" value="Send for CT Review (SCTR)"></td>
          <td width="331" align="center">
              <input type="submit" name="CT Review Complete (CTRC" id="CT Review Complete (CTRC)" value="CT Review Complete (CTRC)"></td>
        </tr>
        <tr>
          <td align="center">
              <input type="submit" name="Cleanup Queries" id="Cleanup Queries" value="Cleanup Queries"></td>
          <td align="center">
              <input type="submit" name="Cleanup  Complete" id="Cleanup  Complete" value="Cleanup  Complete"></td>
        </tr>
        <tr>
          <td colspan="2" align="center"><input type="submit" name="Go_To_Main_Page" id="Go_To_Main_Page" value="Go To Main Page"></td>
        </tr>
      </table>
      <p>&nbsp;</p>
    </form>
    <h1>&nbsp;</h1>
</body>
</html>

and second jsp as below

 <%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <input type="text" value="<%request.getParameter("TSI_Query_Box");%>">
        <input type="text" value="<%request.getParameter("SI_Query_Box");%>">
    </body>
</html>

Here i want to know how to retrieve the textarea values into the second jsp. i heard that i can use hidden values but not sure of how to use them. actually i want this data for submition in my database. please let me know how do i do it.

Thanks

2 Answers 2

2

first of all your function hide(x) must have two parameters as:

function hide(x,y)
{
    document.getElementById(x).style.display='none';
    document.getElementById(y).style.display='block';
}

and when you assign the value in JSP, you must use <%= %> instead of <% %>

so you must change your HTML to:

<input type="text" value="<%=request.getParameter("TSI_Query_Box")%>">

and also Take a look at the answer, How to avoid Java Code in JSP-Files?

Sign up to request clarification or add additional context in comments.

Comments

0

At first change

<input type="text" value="<%request.getParameter("TSI_Query_Box");%>">

to

<input type="text" value="<%= request.getParameter("TSI_Query_Box"); %>">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.