JQuery Select

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jquery Select</title>
</head>
<body>
<form action="#" method="get">
	<select name="city" id="city">
	</select>
	<input type="button" id="sendsms" value="send sms" />
	<input type="reset" value="reset" />
	<button id="submit">submit</button>
</form>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/assets/js/jquery.js"></script>
<script type="text/javascript">
$(function(){
	$('#city').empty();
	$.getJSON("/y/admin/trackcheck.do", {
		page: '1',
		id: Math.random()
		},
		function(data) {
			$.each(data, function(i, v) {
				//$('<option></option>').val(v['cityid']).text(v['name']).appendTo($('#city'));
				$('<option></option>').val(v['trackID']).text(v['trackName']).appendTo($('#city'));
			});
	});
	
	$('#city').change(function(){
		var val = $(this).val();
		alert(val);
	});
	
	dologin();
	sendsms();
});

// ajax登陆
function dologin() {
	$('#submit').click(function(){
		alert('submit clicked');
	});
}

// click the 'send sms'
function sendsms(){
	$('#sendsms').click(function(){
		disableSendSms();
	});
}

// 10秒后重发短信
var t = 10;
function disableSendSms(){
	$('#sendsms').attr('disabled', 'disabled');
	if(t > 0){
		t--;
		var timer = setTimeout('disableSendSms()', 1000);
		$('#sendsms').val(t + ' senond can send sms again');
		
	} else {
		$('#sendsms').removeAttr('disabled');
		$('#sendsms').val('send sms');
		t = 10;
	}
	
}
</script>
</body>
</html>

相关推荐