Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在经典ASP和jQuery中使用复选框值填充文本框_Javascript_Jquery_Asp Classic - Fatal编程技术网

Javascript 在经典ASP和jQuery中使用复选框值填充文本框

Javascript 在经典ASP和jQuery中使用复选框值填充文本框,javascript,jquery,asp-classic,Javascript,Jquery,Asp Classic,以下是我的代码片段: response.write "<th align=left><font size=2>" response.write "1. <input type=checkbox class='checkboxes' value='ORG'>Organization" response.write "</font> </th>" response.write "<th align=left&

以下是我的代码片段:

 response.write "<th align=left><font size=2>"
    response.write "1. <input type=checkbox class='checkboxes' value='ORG'>Organization"
    response.write "</font> </th>"
    response.write "<th align=left><font size=2>"
    response.write "2. <input type=checkbox  value='OpType' class='checkboxes'>Operation Type"
    response.write "</font> </th>"
    response.write "<th align=left><font size=2>"
    response.write "3. <input type=checkbox checked  value='YEAR' class='checkboxes'>Year"
    response.write "</font> </th>"

response.write "<tr><td colspan='3'> <input name='DISTRIBUTION' size='45' /></td></tr>"
response.write“”
回答。写“1.组织”
响应。写入“”
响应。写入“”
响应。写入“2.操作类型”
响应。写入“”
响应。写入“”
回答:写“3年”
响应。写入“”
响应。写入“”
下面是javascript

<script type="text/javascript" src="../Scripts/jquery-1.9.1.js"></script>
$('.checkboxes').change(function () {
    alert("1");
    $("input[Title='DISTRIBUTION']").val("");
    if ($('.checkboxes').is(':checked')) {
        $("input[Title='DISTRIBUTION']").val("Yes");
    }
});

$('.checkbox').change(函数(){
警报(“1”);
$(“输入[Title='DISTRIBUTION'].val(“”);
如果($('.checkbox')。是(':checked')){
$(“输入[Title='DISTRIBUTION']”)val(“是”);
}
});

我没有看到警报,所以它看起来不像被解雇了。我做错什么了吗?

也许脚本是在文档完全构建之前执行的?只是一个猜测,但请尝试将jquery代码包装在其中

$(document).ready(function () { ... });

您还应该研究KnockoutJs-它会让您的生活更轻松…

我怀疑这只是一种不等待DOM准备好再分配事件处理程序的情况。试试这个

$(function() {
    $('.checkboxes').change(function () {
        alert("1");
        $("input[Title='DISTRIBUTION']").val("");
        if ($('.checkboxes').is(':checked')) {
            $("input[Title='DISTRIBUTION']").val("Yes");
        }
    });
});