检查复选框值onclick [英] checking checkbox values onclick

查看:97
本文介绍了检查复选框值onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我在读取和发送复选框值方面遇到问题我尝试使用ajax但是它不起作用

 function defaultt(id){
$ .ajax({

类型:POST,
数据:id =+ id,
url:defaultt.php,
成功:函数(msg){
$('#'+ id).fadeOut(300);
}
});



代码:

 <   td  >  <  表格 >  <  输入    type   = 复选框    name   =  state    id   =  state  class   =  check     已检查    onClick   ='  javascript:defaultt(。 $ row ['  ID']       );'   >  



检索其他page.php中的代码:

 <? php $ state = $ _ POST ['  id'] 
// 此处插入到db语句
?>



我使用过(vishnu Prajapati)代码:

首先非常感谢你的时间。我用你的代码但是ajax没跟我合作

什么都没发生

我想要一种方法来提交没有类型提交的输入?为什么ajax不起作用?

解决方案

.aja x({

类型:POST,
数据:id =+ id,
url:defaultt.php,
成功:函数( msg){


('#'+ id).fadeOut(300);
}
});



代码:

 <   td  >  <  表格 >  <  输入    type   = 复选框    name   =  state    id   =  state  class   =  check     已检查    onClick   ='  javascript:defaultt(。


row [' ID'] );' >



检索其他page.php中的代码:

< pre lang =HTML> <? php


hello I have problem in reading and sending checkbox value I tried using ajax but it didn't work

function defaultt(id) {
        $.ajax({

            type : "POST",
            data : "id=" + id,
            url : "defaultt.php",
            success : function(msg) {
                $('#' + id).fadeOut(300);
            }
        });


code:

<td><form><input type="checkbox" name="state" id="state"class="check"  checked onClick='javascript:defaultt(" . $row['ID'] . ");' >


retrieve code in other page.php:

<?php $state=$_POST['id']
      //here insert to db statment
?>


I used (vishnu Prajapati) code:
first of all thank you very much for your time. I used your code but the ajax didn work with me
nothing happend
I want a way to submit without the input of type submit? why the ajax didn't work?

解决方案

.ajax({ type : "POST", data : "id=" + id, url : "defaultt.php", success : function(msg) {


('#' + id).fadeOut(300); } });


code:

<td><form><input type="checkbox" name="state" id="state"class="check"  checked onClick='javascript:defaultt(" .


row['ID'] . ");' >


retrieve code in other page.php:

<?php


这篇关于检查复选框值onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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