<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里面的中括号中或者如何动态的取一个值赋到中括号里面。

解决方案 »

  1.   

    $("#orz").change(function(){
        $("#get").attr("onfocus", "WdatePicker({disabledDays:" + $(this).val() + "})");
    });
      

  2.   

    我用的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>
      

  3.   

    <input type="text" value="" id="get" />
    <script type="text/javascript">
    //换个思路
    $("#get").focus( function() {
    WdatePicker({disabledDays: $("#orz").val()});
    });
    </script>
      

  4.   

    兄台,能帮我在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>
      

  5.   

    选了select以后再点击input框,disabledDays:[]里面还是空的啊
      

  6.   

    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>
      

  7.   

      onFocus="WdatePicker({disabledDays:[]})" 
    是我一个日历控件里面的函数。
      

  8.   

     $("#get").val($("#orz option:selected").text());