-1

以下のjspページを作成しています。

<%@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)
        {
            document.getElementById(x).style.display='block';
        }
    function hide(x)
        {
            document.getElementById(x).style.display='none';
        }
        function handleKeyEvent(e) {
    var charCode;


    if (e && e.which) {
        charCode = e.which;
    } else if (window.event) {
        e = window.event;
        charCode = e.keyCode;
    }

    if (charCode == 13) {
        //document.getElementById("yourForm").submit();
        var m=document.getElementById(e);
        alert(m);
                hide(x);
    }
}


        </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')">              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="handleKeyEvent('TSI_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')"> 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="handleKeyEvent('SI_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"></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>

テキストエリアにテキストを入力してEnterキーを押すと、テキストが表示されるのを見たいです。現在のケースでは、メッセージ [オブジェクト] を警告しています。また、ラジオ ボタンをチェックするときに、TSI クエリ ラジオ ボタンに続いて SI クエリ ラジオ ボタンをチェックするか、その逆をチェックすると、両方が表示されます。

スクリーンショットについては、このリンクをご覧ください

http://jsfiddle.net/dYy26/

ありがとう。

4

2 に答える 2

0

これをチェックして:

<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';
        document.getElementById('Ship_IDl').style.display='block';
    }
function hide(x,y)
    {
        document.getElementById(x).style.display='none';
        document.getElementById(y).style.display='block';
        document.getElementById('Ship_IDl').style.display='none';
    }

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);
    }
}
    </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','SI_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','TSI_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>
于 2013-03-07T12:26:21.690 に答える
0

このコードを確認してください:

<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';
        document.getElementById('Ship_IDl').style.display='block';
    }
function hide(x,y)
    {
        document.getElementById(x).style.display='none';
        document.getElementById(y).style.display='block';
        document.getElementById('Ship_IDl').style.display='none';
    }
function handleKeyEvent(e) {
var charCode;
if (e && e.which) {
    charCode = e.which;
} else if (window.event) {
    e = window.event;
    charCode = e.keyCode;
}
if (charCode == 13) {
    //document.getElementById("yourForm").submit();
    var m=document.getElementById(e);
    alert(m);
            hide(x);
}
}
</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','SI_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="handleKeyEvent('TSI_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','TSI_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="handleKeyEvent('SI_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"></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>
于 2013-03-07T11:33:52.497 に答える