dongliming2416 2019-02-23 06:27
浏览 42

点击复选框时它显示多个值?

view:

<script>
    $(document).ready(function(){
        $(".uid").click(function(){
            jid = $(".jid").attr("id");
            uid = $(':checked').map(function() { 
                        return this.id; 
                  }).get().join(',');
            $.ajax({
                type:"POST",
                data:{"jid":jid, "uid":uid},
                url:"<?php echo base_url(); ?>shortlist",
                success:function(data){
                    $(".stage_shortlist").html(data);
                }
            });
        });
        $(document).on("click",".uid_short",function(){
            jid_short = $(".jid_short").attr("id");
            uid_short = $(':checked').map(function() { 
                            return this.id; 
                        }).get().join(',');
            alert(jid_short);
            alert(uid_short);
        });
    });
</script>
<h2>Received</h2>
<section>
    <table class="table table-hover js-basic-example dataTable table-custom m-b-0">
        <thead>
            <tr>
                <th>Name</th>  
                <th>Shortlist</th>
            </tr>
        </thead>
        <tbody>
            <?php
                $this->db->select('*');
                $this->db->from('upload_detail');
                $where = "jid='".$row['job_id']."' and share_with_emp='1'";
                $this->db->where($where);
                $sql = $this->db->get();
                if($sql->num_rows() > 0)
                {
                    $result = $sql->result_array();
                    foreach($result as $recieve)
                    {
            ?>
                        <tr>
                            <td><?php echo $recieve['fname']; ?></td>
                            <td>
                                <div class="fancy-checkbox">
                                    <label>
                                        <input type="hidden" name="jid" class="jid" id="<?php echo $recieve['jid']; ?>"/>
                                        <?php 
                                            if($recieve['shortlist']=='1')
                                            { 
                                                echo '<input type="checkbox" name="uid" id="" class="uid" checked disabled><span>Shortlist</span>'; 
                                            }
                                            else
                                            {
                                                echo '<input type="checkbox" name="uid" id="'.$recieve["uid"].'" class="uid"><span>Shortlist</span>';
                                            }
                                        ?>
                                    </label>
                                </div>
                            </td>
                        </tr>
            <?php
                    }
                }
                else
                {
                    echo "<p>No resume Found</p>";
                }
            ?>
        </tbody>
    </table>
</section>
<h2>Shortlisted</h2>
<section>
    <table class="table table-hover js-basic-example dataTable table-custom m-b-0">
        <thead>
            <tr>
                <th>Name</th>
                <th>Shortlist</th>
            </tr>
        </thead>
        <tbody class="stage_shortlist">
            <?php
                $this->db->select('*');
                $this->db->from('upload_detail');
                $where = "jid='".$row['job_id']."' and shortlist='1'";
                $this->db->where($where);
                $sql_short = $this->db->get();
                $result_short = $sql_short->result_array();
                foreach($result_short as $short)
                {
            ?>
                    <tr>
                        <td><?php echo $short['fname']; ?></td>
                        <td>
                            <div class="fancy-checkbox">
                                <label>
                                    <input type="hidden" name="jid_short" class="jid_short" id="<?php echo $short['jid']; ?>"/>
                                    <?php 
                                        if($short['interview']=='1')
                                        { 
                                            echo '<input type="checkbox" name="uid_short" id="" class="uid_short" checked disabled><span>Shortlist</span>'; 
                                        }
                                        else
                                        {
                                            echo '<input type="checkbox" name="uid_short" id="'.$short["uid"].'" class="uid_short"><span>Shortlist</span>';
                                        }
                                    ?>
                                </label>
                            </div>
                        </td>
                    </tr>
            <?php
                }
            ?>
        </tbody>
    </table>
</section>

controller:

<?php
public function shortlist()
{
    $jid = $this->input->post('jid');
    $uid = explode(",",$this->input->post('uid'));
    $data = array('shortlist'=>'1');
    foreach($uid as $user_id)
    {
        $where = "uid='".$user_id."' and jid='".$jid."'";
        $this->db->where($where);
        $sql = $this->db->update('upload_detail',$data);
    }
    if($sql==true)
    {
        $this->db->select('*');
        $this->db->from('upload_detail');
        $where = "jid='".$jid."' and shortlist='1'";
        $this->db->where($where);
        $sql_short = $this->db->get();
        $result_short = $sql_short->result_array();
        foreach($result_short as $short)
        {
?>
            <tr>
                <td><?php echo $short['fname']; ?></td>
                <td>
                    <div class="fancy-checkbox">
                        <label>
                            <input type="hidden" name="jid_short" class="jid_short" id="<?php echo $short['jid']; ?>"/>
                            <?php 
                                if($short['interview']=='1')
                                { 
                                    echo '<input type="checkbox" name="uid_short" id="" class="uid_short" checked disabled><span>Shortlist</span>'; 
                                }
                                else
                                {
                                    echo '<input type="checkbox" name="uid_short" id="'.$short["uid"].'" class="uid_short"><span>Shortlist</span>';
                                }
                            ?>
                        </label>
                    </div>
                </td>
            </tr>
<?php
        }
    }
    else
    {
        echo '<p>Unable to proceed!</p>';
    }
}
?>

In this code I am update shortlist value 1 onclick uid which is the part of recieved heading section and response call from shortlist controller which is work perfectly but problem is that when I click on class uid_short it alert multiple value inside the alert(uid_short); I don't know what where am I doing wrong? Please help me to solve this issue.

Thank You

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大