Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.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 只读并仅将选中单选按钮保存到“a”;MYSQL中的特定列PHP&;AJAX_Javascript_Php_Html_Mysql_Ajax - Fatal编程技术网

Javascript 只读并仅将选中单选按钮保存到“a”;MYSQL中的特定列PHP&;AJAX

Javascript 只读并仅将选中单选按钮保存到“a”;MYSQL中的特定列PHP&;AJAX,javascript,php,html,mysql,ajax,Javascript,Php,Html,Mysql,Ajax,使用的技术: 服务器端:PHP 数据库:MYSQL 客户端:调用PHP的Ajax 客户端:HTML 可用于:Phonegap 我有四个单选按钮在一个单选组在HTML 母亲 父亲 自我 其他 我的表格中的4列是: | DBMother | DBFather | DBSelf | DBOthers | 如果我选择Mother单选按钮,该值应转到并保存在列DBMother下,其余列应保持空白 当我在HTML中选择单选按钮Self时,该值应该在Mysql DB columnDBSelf下保存,其余

使用的技术:

  • 服务器端:PHP
  • 数据库:MYSQL
  • 客户端:调用PHP的Ajax
  • 客户端:HTML
  • 可用于:Phonegap
我有四个单选按钮在一个单选组在HTML

  • 母亲
  • 父亲
  • 自我
  • 其他
  • 我的表格中的4列是:

    | DBMother | DBFather | DBSelf | DBOthers |
    
    如果我选择
    Mother
    单选按钮,该值应转到并保存在列
    DBMother
    下,其余列应保持空白

    当我在HTML中选择单选按钮
    Self
    时,该值应该在Mysql DB column
    DBSelf
    下保存,其余的列应该保持空白

    我在google上尝试了一些代码,但这些代码是用来将信息保存在一个DB列中的

    我想服务器端需要PHP代码,客户端需要Ajax代码

    <html>
    <head>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
      </script>
      <script type="text/javascript">
        $(document).ready(function(){
    
          $("#submit").click(function(){
    
            var game=$('input[type="radio"]:checked').val();
    
            if($('input[type="radio"]:checked').length == "0") {
              alert("Select any value");
            }
            else {
              $.ajax({
                type: "POST",
                url: "ajax-check.php",
                data: "game="+game,
                success: function() {
                  $("#msg").addClass('bg');
                  $("#msg").html("value Entered");
                }
              });
            }
            return false;
          });
        });
      </script>
    </head>
    <body>
      <div id="msg"></div>
      <form method="post" action="">
        Select:<br/>
        <input type="radio" name="game" value="Mother">
        <input type="radio" name="game" value="Father">
        <input type="radio" name="game" value="Self">
        <input type="radio" name="game" value="Others">
        <input type="submit" name="submit" id="submit">
      </form>
    </body>
    </html>
    
    
    $(文档).ready(函数(){
    $(“#提交”)。单击(函数(){
    var game=$('input[type=“radio”]:checked').val();
    如果($('input[type=“radio”]:checked')。长度==“0”){
    警报(“选择任何值”);
    }
    否则{
    $.ajax({
    类型:“POST”,
    url:“ajax check.php”,
    数据:“游戏=”+游戏,
    成功:函数(){
    $(“#msg”).addClass('bg');
    $(“#msg”).html(“输入值”);
    }
    });
    }
    返回false;
    });
    });
    选择:

    请显示您尝试的代码,我们不是来为您编写所有代码的。@Barmar我已将代码张贴在问题的下方。答案是为了解决问题,而不是问题的延续。@Barmar代码粘贴在问题中。。