"HTML" "JavaScript"
コード <Script> <!-- function fncDisp() { label1.innerHTML = document.f.nam.value; label2.innerHTML = document.f.namae.value; label3.innerHTML = document.f.mail.value; } function shwSelect() { //セレクトボックスの値(数値)を取得 var num = document.f.depart.selectedIndex; // 値(value値)を取得 var str = document.f.depart.options[num].value; document.getElementById("label4").innerHTML = str; //セレクトボックスの値(数値)を取得 var num = document.f.title.selectedIndex; // 値(value値)を取得 var str = document.f.title.options[num].value; document.getElementById("label5").innerHTML = str; } function FormSubmit() { var target = document.getElementById("search"); // 追加。 document.getElementById('s1').value = document.f.nam.value; document.getElementById('s2').value = document.f.namae.value; document.getElementById('s3').value = document.f.mail.value; document.getElementById('s4').value = document.f.depart.value; document.getElementById('s5').value = document.f.title.value; target.method = "post"; target.submit(); } function FormExport() { var target = document.getElementById("export"); document.getElementsByName("nam")[0].value = document.getElementsByName("nam")[0].value document.getElementsByName("namae")[0].value = document.getElementsByName("namae")[0].value document.getElementsByName("mail")[0].value = document.getElementsByName("mail")[0].value document.getElementsByName("depart")[0].value = document.getElementsByName("depart")[0].value document.getElementsByName("title")[0].value = document.getElementsByName("title")[0].value target.method = "post"; target.submit(); } --> </Script> <title>社員管理システム</title> </head> <body> <jsp:include page="nav1.jsp" /> <form name="f" action=""> <div class="containers"> <table class="table"> <tr> <th>従業員名</th> <td> <span id="label1"></span> <input type="text" name="nam" value="<c:out value="${dto.nam}" />" maxlength="128" size="60"/></td> </tr> <tr> <th>従業員名(フリガナ)</th> <td> <span id="label2"></span> <input type="text" name="namae" value="<c:out value="${dto.namae}" />" maxlength="128" size="60"/></td> </tr> <tr> <th>メールアドレス</th> <td><span id="label3"></span> <input type="text" name="mail" value="<c:out value="${dto.mail}" />" maxlength="128" size="60"/></td> </tr> <tr> <th>部署</th> <td><span id="label4"></span> <select name="depart"> <option value="">選択してください</option> <option value="システム事業部">システム事業部</option> <option value="活用事業部">活用事業部</option> <option value="営業部">営業部</option> <option value="役員">役員</option> </select> </td> </tr> <tr> <th>役職</th> <td><span id="label5"></span> <select name="title"> <option value="">選択してください</option> <option value="CEO">CEO</option> <option value="COO">COO</option> <option value="CTO">CTO</option> <option value="部長">部長</option> <option value="係長">係長</option> <option value="主任">主任</option> </select> </td> </tr> </table> </div> <input type="button" name="btn" value="確認" onClick="fncDisp(), shwSelect()"> </form> <form id="search" action="search" method="POST"> <input type="hidden" id="s1" name="label1" /> <input type="hidden" id="s2" name="label2" /> <input type="hidden" id="s3" name="label3" /> <input type="hidden" id="s4" name="label4" /> <input type="hidden" id="s5" name="label5" /> <input class="btn btn-success center-block" name="search" value="検索" onClick="FormSubmit();" /> </form> <br />
社内研修中の初心者です。 社内にJavaScriptに詳しい人がいないのでお聞きします。 現在JSPとサーブレットを使い、MySQLのデータから社員を検索して編集するシステムを作っています。 入力フォームに入力し、検索ボタンを押してMySQLから取り出した値をテーブル表示しています。 正常に動いていたのですが、仕様が変更になりました。 入力した値を一度画面に出力(確認ボタンを押すと出力)して、その出力した値から検索することになりました。 JavaScriptを使って画面に出力することは出来たのですが、検索ボタンを押しても値が取り出せません。 ソースが間違っているのか、JSPにJavaScriptを入れると正確に動作しないのでしょうか。 よろしくお願いいたします。 追記 17:32 最新のコードを載せました。
回答1件
あなたの回答
tips
プレビュー