我的第一步

<script type="text/javascript">


function validate(id){
var idNum = document.getElementById(id).value;
var a ;
a.confirm("確定要重置嗎", function(result)){
if(result){
$.ajax{

}
url:remove/edit.do
type:'post',
data:{"REMOVE_ID":idNum},
dataType:'text'
success:function(result){
//這是用來接收從後臺傳過來的值。
if(result==1){
alert("請輸入正確的放假號");
}else{
alert("重置成功");
}

}
}
}
}
}

}

</script>

/*

//寫後臺代碼

@RequestMapping("/edit")

public void edit(httpServletResponse response String ROOM_ID){

RemoveService removeService;

String roomId = removeService.findROOM_IDBYId(ROOM_ID);
PrintWriter pw = response.getWriter();
if(roomId==null){
pw.print(1)
}
removeService.edit();//這個方法是用來修改房間號狀態爲3
}

*/


</head>
<body>

<ol >
<li><strong>一個輸入框,一個重置按鈕。</strong></li>
<li>輸入內容爲空,點擊重置時,提醒輸入房間號不能爲空<li>
<li>輸入不爲數字,點擊重置時,提醒輸入房間號只能爲數字</li>
<li>輸入爲數字,點擊重置時,房間號不存在,提示房間號不存在</li>
<li>輸入爲數字,點擊重置,房間號重置成功,提示用戶重置房間號成功</li>
</ol>


<p>詳細步驟:寫一個輸入框和重置按鈕,添加ajax方法(validate())傳房間號到後臺</p>
<table>
<tr>
<td><input id="num" type="text" onchange="if(/\D/.test(this.value){alert('只能輸入數字');this.value('');}"></td>
<td><input type="button" value="重置" onclick="validate('num');"></td>
</tr>
</table>
</div>

</body>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章