使用复选框即创建阿贾克斯工作 [英] Working with checkbox which is creating by Ajax

查看:174
本文介绍了使用复选框即创建阿贾克斯工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正与阿贾克斯的项目。 我与姓名,地址,邮递code有用户的形式。 在进入c中的匹配行的名称,地址或交$ C $中显示阿贾克斯文件。

I am working with ajax project. I have a form of user in with name, address , postcode . on entering the name, address or postcode the matching rows is shown by ajax file in .

等选择复选框,我希望做一些进一步的活动。

so on select the checkbox i want to do some further activity.

我的HTML code是

my html code is

Address : <input type="text" name="user_name" id="from_location" value="" class="in_form" />
 <div id="user"></div>

和jQuery的code是

and jQuery code is

$.ajax({
                url: "ajax_user.php",
                data: {
                    address: address,

                 },
                dataType: "html",
                type: "POST",
                success: function(result){
                        $("#user").append(result);
                    }
                })
            }

和Ajax用户PHP是

and ajax user php is

$sql= "SELECT * FROM instructor_mst WHERE sex='$sex' AND car_type='$car_type' AND address Like '%$address%' ";
        if (!$sqli=mysql_query($sql)){
            echo mysql_error();
        }
        $num_rows= mysql_num_rows($sqli);
        if($num_rows != 0)
        {?>
        <table border="0" class="form_ins" >
        <?
        while ($row = mysql_fetch_array($sqli)) 
        {

        ?>    
        <tr>
            <td>

            </td>
            <td>
                Name
            </td>   

            <td>
                Address
            </td>



        </tr>
        <tr>
            <td>
                <input type="checkbox" name="select" value"<?php echo $row['id'];?>"> 
            </td>
            <td>
                <?php echo $row['name'];?>
            </td>   

            <td>
                <?php echo $row['address'];?>
            </td>



        </tr>
        </table
        <?}

在结果我得到了像

复选框|用户名|地址

现在的选择,我想提出的其他活动的复选框.... 我没有得到我怎么能做到这一点......所有的答案将是AP preicieted

now on selecting the checkbox i want to submit for other activity.... I am not getting how can i do this...All answer will be appreicieted

推荐答案

随着复选框被动态地添加 -

As your checkbox being dynamically added -

 $(document).on('change','input[type=checkbox]',function(){
       if($(this).is(':checked')){
         // do something
       }
 });

或者,如果你有你的复选框的ID -

Or if you have an ID of your checkbox -

$(document).on('change','#checkBoxID',function(){
   if($(this).is(':checked')){
     // do something
   }
});

这篇关于使用复选框即创建阿贾克斯工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆