<input type="text" value="" id="get" onFocus="WdatePicker({disabledDays:[<?=$strdoctortime;?>]})"/> />
<select id="orz">
<option value="1">111</option>
<option value="2">222</option>
<option value="3">333</option>
</select>
<script>
$("#orz").change(function(){
$("#get").val($(this).val());
});
</script>我想把select中的值赋到input中的onFocus里面的中括号中或者如何动态的取一个值赋到中括号里面。
$("#get").attr("onfocus", "WdatePicker({disabledDays:" + $(this).val() + "})");
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head><body>
<input type="text" value="" id="get" onFocus="WdatePicker({disabledDays:[]})"/>
<select id="orz">
<option value="1">111</option>
<option value="2">222</option>
<option value="3">333</option>
</select>
<script>
$("#orz").change(function(){
$("#get").attr("onfocus", "WdatePicker({disabledDays:" + $(this).val() + "})");
});
</script></body>
</html>
<script type="text/javascript">
//换个思路
$("#get").focus( function() {
WdatePicker({disabledDays: $("#orz").val()});
});
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head><body>
<select id="orz">
<option value="1">111</option>
<option value="2">222</option>
<option value="3">333</option>
</select>
<input type="text" value="" id="get" onFocus="WdatePicker({disabledDays:[]})" />
<script type="text/javascript">
//换个思路
$("#get").focus( function() {
WdatePicker({disabledDays: $("#orz").val()});
});
</script></body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
</head><body>
<input type="text" value="" id="get" />
<select id="orz">
<option value="1">111</option>
<option value="2">222</option>
<option value="3">333</option>
</select>
<script>
function WdatePicker(o) {
$("body").append(o.disabledDays);
}
$("#get").focus( function() {
WdatePicker({disabledDays: $("#orz").val()});
});
</script>
</body>
</html>
是我一个日历控件里面的函数。