こんにちは。
質問です。
下記のJSPにjavascriptを組み込みました。
そこで1点問題が生じまして、1番下のほうの登録や更新のOKボタン
の部分で、どうしてもボタンの名称をOKに変更してしまうと処理に
不具合が生じてしまいます。何かいい方法がありませんでしょうか。
よろしくお願いいたします。
今は登録時がinsert、更新時がupdateにボタンの名称がなってしまっております。
lang
1<%@ page language="java" contentType="text/html; charset=EUC_JP" 2 pageEncoding="Windows-31J"%> 3<%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld"%> 4<%@ taglib prefix="fn" uri="/WEB-INF/tld/fn.tld"%> 5<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 6<html> 7<head> 8<meta http-equiv="Content-Type" content="text/html; charset=EUC_JP"> 9<c:import url="./head.jsp" /> 10<link rel="stylesheet" type="text/css" href="../css/customerDetail.css"> 11<script type="text/javascript" src="../js/dialog.js" charset="UTF-8"> 12</script> 13<title>編集画面</title> 14<script type="text/javascript"> 15 16 17function touroku(){ 18 19 // 「OK」時の処理開始 + 確認ダイアログの表示 20 if(window.confirm('本当に登録してよろしいですか?')){ 21 22 location.href = "/Kadai/page/customerDetail.jsp"; 23 24 } 25 // 「OK」時の処理終了 26 27 } 28 29function kousin(){ 30 31 // 「OK」時の処理開始 + 確認ダイアログの表示 32 if(window.confirm('本当に更新してよろしいですか?')){ 33 34 location.href = "/Kadai/page/customerList.jsp"; 35 36 } 37 // 「OK」時の処理終了 38 39 } 40 41function sakujyo(){ 42 43 // 「OK」時の処理開始 + 確認ダイアログの表示 44 if(window.confirm('本当に削除してよろしいですか?')){ 45 46 location.href = "/Kadai/page/customerList.jsp"; 47 48 } 49 // 「OK」時の処理終了 50 51 } 52 53</script> 54 55 56 57 58</head> 59<body> 60 61 62 <form action="./CustomerDetail" method="post"> 63 <table> 64 <tr> 65 <th>顧客ID</th> 66 <td><c:choose> 67 <c:when test="${processType == 'insert'}"> 68 <input type="text" name="id" size="12" value="${id}"> 69 </c:when> 70 <c:otherwise> 71 <c:out value="${id}" /> 72 <input type="hidden" name="id" value="${id}"> 73 </c:otherwise> 74 </c:choose></td> 75 </tr> 76 <tr> 77 <th>顧客漢字名</th> 78 <td><input type="text" name="name" size="20" value="${name}"></td> 79 </tr> 80 <tr> 81 <th>顧客カナ名</th> 82 <td><input type="text" name="kana" size="20" value="${kana}"></td> 83 </tr> 84 <tr> 85 <th>性別</th> 86 <td><select name="gender"> 87 <c:forEach var="generalDto" items="${genderList}" varStatus="status"> 88 <c:choose> 89 <c:when test="${generalDto.detailCode == gender}"> 90 <option value="${generalDto.detailCode}" selected><c:out value="${generalDto.contents1}" /></option> 91 </c:when> 92 <c:otherwise> 93 <option value="${generalDto.detailCode}"><c:out value="${generalDto.contents1}" /></option> 94 </c:otherwise> 95 </c:choose> 96 </c:forEach> 97 </select> 98 </td> 99 </tr> 100 <tr> 101 <th>身長</th> 102 <td><input type="text" name="height" size="12" 103 value="${height}">cm</td> 104 </tr> 105 <tr> 106 <th>体重</th> 107 <td><input type="text" name="weight" size="12" 108 value="${weight}">kg</td> 109 </tr> 110 <tr> 111 <th>生年月日</th> 112 <td><input type="text" name="birthday" size="12" 113 value="${birthday}">(yyyy/MM/ddで入力してください)</td> 114 </tr> 115 <tr> 116 <th>郵便番号</th> 117 <td><input type="text" name="zipCode" size="14" 118 value="${zipCode}">(ハイフン無しで入力してください)</td> 119 </tr> 120 <tr> 121 <th>住所</th> 122 <td><input type="text" name="address" size="40" 123 value="${address}"></td> 124 </tr> 125 <tr> 126 <th>電話番号</th> 127 <td><input type="text" name="phone" size="14" value="${phone}">(ハイフンありで入力してください)</td> 128 </tr> 129 <c:choose> 130 <c:when test="${processType == 'insert'}"> 131 </c:when> 132 <c:otherwise> 133 <tr> 134 <th>削除</th> 135 <td><input type="checkbox" name="deleteFlag" size="12" 136 value="${1}"></td> 137 </tr> 138 </c:otherwise> 139 </c:choose> 140 141 142 </table> 143 144 <c:choose> 145 <c:when test="${processType == 'insert'}"> 146 <input type="submit" name="processType" value="insert" onClick="touroku()"/> 147 </c:when> 148 <c:otherwise> 149 <input type="submit" name="processType" value="update" onClick="kousin()"/> 150 </c:otherwise> 151 </c:choose> 152 <input type="submit" value="一覧へ" name="backList" /> 153 </form> 154</body> 155</html>

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/06/29 06:28
2015/06/29 06:53
2015/06/29 06:55
2015/06/29 07:40
2015/06/29 07:44
2015/06/29 08:23
2015/06/29 09:34
2015/06/29 09:40
2015/06/29 10:19
2015/06/29 10:21
2015/06/29 10:36
2015/06/29 10:43
2015/06/29 10:43