0

我试图返回我的复选框的值,你能帮我吗,因为如果值为 1,我仍然无法返回值我希望我的复选框中会有一个检查

这是我的代码:

    <input  type="hidden" name="stud_no[]" value="<?php echo $row['student_no'];?>">


    <input  type="text" name="prelim[]" value="<?php echo $row['prelim_pts']?>"  id="prelim_<?php echo $row['student_no'];?>" class="txtprelim" ></td>
    <td><input  type="text" name="midterm[]" value="<?php echo $row['midterm_pts']?>"  id="midterm_<?php echo $row['student_no'];?>" class="txtmidterm" ></td>
    <td> <input  type="text" name="final[]" value="<?php echo $row['finals_pts']?>" id="final_<?php echo $row['student_no'];?>" class="txtfinal" ></td>

<td>

<input type="text" name="average[]" id="average_<?php echo $row['student_no']; ?>" value="<?php echo $row['average_pts']; ?>"  readonly="readonly"> 

</td>
<td><input type="checkbox" name="disable[]" id="able" value="<?php echo $row['disable_comp'];?>" class="dis"> </td>

<?php

    echo "</tr>";
    }
}

    ?>
    <input type="hidden" name="sec_no" value="<?php echo $_GET["section_no"]; ?>" />
    <input type="submit" value="UPDATE">
    </form>

<script type="text/javascript" src="jquery-ui-1.8.2.custom.min.js"></script>
    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>

    <script type="text/javascript">
    //var bIsFirebugReady = (!!window.console && !!window.console.log);

    $(document).ready(function(){

        p="";
        m="";
        f="";

 var computeValues = function(){
            var id = $(this).attr("id").replace("prelim_", "").replace("midterm_", "").replace("final_", "");
            p = $("#prelim_" + id).val();
            m = $("#midterm_" + id).val();
            f = $("#final_" + id).val();
            Compute(p, m, f, id);
        };

        $("input").bind('keyup', computeValues);

        function Compute(p, m, f, studno) {
            var average;
            average = parseFloat(p * 0.3) + parseFloat(m * 0.3) + parseFloat(f * 0.4);
            $("#average_" + studno).val(average.toFixed());     
        }

        $(".dis").change(function() {
            var val = $(this).val();
            if ($(this).is(':checked')) {
                var checked = $('input[type=checkbox]').is(':checked');
                $("input").unbind('keyup', computeValues);




            }
             else {
                $("input").bind('keyup', computeValues).trigger('keyup');

            }
        });
    });

</script>
4

2 回答 2

1

Try this:

var checked=$("#chkboxid").is(':checked');

checked will contain either true or false

于 2013-04-08T06:26:19.200 回答
0
var x = $(this).prop('checked');
于 2013-04-08T06:12:21.670 回答