jquery如何将下拉单中的值赋到input中

luobutou0827 2012-07-10 03:10:40

<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里面的中括号中或者如何动态的取一个值赋到中括号里面。
...全文
310 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
luobutou0827 2012-07-11
  • 打赏
  • 举报
回复
还有人能回答一下吗
gf05011 2012-07-10
  • 打赏
  • 举报
回复
$("#get").val($("#orz option:selected").text());
luobutou0827 2012-07-10
  • 打赏
  • 举报
回复
onFocus="WdatePicker({disabledDays:[]})"
是我一个日历控件里面的函数。

[Quote=引用 8 楼 的回复:]
WdatePicker()函数是怎么定义的,下面是我的测试代码:


HTML code
<!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.o……
[/Quote]
乌镇程序员 2012-07-10
  • 打赏
  • 举报
回复
WdatePicker()函数是怎么定义的,下面是我的测试代码:

<!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=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>
luobutou0827 2012-07-10
  • 打赏
  • 举报
回复
选了select以后再点击input框,disabledDays:[]里面还是空的啊
luobutou0827 2012-07-10
  • 打赏
  • 举报
回复
兄台,能帮我在IE里面调试一下吗,我在ie,google里面还是不行。

<!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>
<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>

[Quote=引用 5 楼 的回复:]
HTML code
<input type="text" value="" id="get" />
<script type="text/javascript">
//换个思路
$("#get").focus( function() {
WdatePicker({disabledDays: $("#orz").val()});
});
</script>
[/Quote]
乌镇程序员 2012-07-10
  • 打赏
  • 举报
回复
<input type="text" value="" id="get" />
<script type="text/javascript">
//换个思路
$("#get").focus( function() {
WdatePicker({disabledDays: $("#orz").val()});
});
</script>
luobutou0827 2012-07-10
  • 打赏
  • 举报
回复
我用的IE和google都不行啊。
<!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>
JiaoPengJay 2012-07-10
  • 打赏
  • 举报
回复
火狐浏览器测试你的代码是可以的,这里说下你多了这个/>
你用的是什么浏览器
luobutou0827 2012-07-10
  • 打赏
  • 举报
回复
兄台,没有实现啊。
[Quote=引用 1 楼 的回复:]
JScript code
$("#orz").change(function(){
$("#get").attr("onfocus", "WdatePicker({disabledDays:" + $(this).val() + "})");
});
[/Quote]
乌镇程序员 2012-07-10
  • 打赏
  • 举报
回复
$("#orz").change(function(){
$("#get").attr("onfocus", "WdatePicker({disabledDays:" + $(this).val() + "})");
});

87,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧