简体   繁体   English

Javascript不起作用(不显示警报框)

[英]Javascript not working (Not showing alert box)

Main Form 主要形式

I m trying to make a feedback form but unable to get the values of radio button. 我试图制作一个反馈表,但无法获取单选按钮的值。 I m using BootStrap and PHP. 我正在使用BootStrap和PHP。

<form class="form-horizontal" id="feedbackForm" role="form" method="post" action="adddetails.php">
  <table class="table table-bordered">
  <tr>
    <tr>
    <td><b>No.</b></td>
    <td><b>Parameter</b></td>
    <td align="center" colspan="5"><b>Faculty</b></td>
  </tr>
        <td></td>
        <td align="right"><b>Faulty Name</b> <i>[Abbreviation]</i></td>
        <td><b>JS</b></td>
        <td><b>AT</b></td>
        <td><b>GK</b></td>
        <td><b>PS</b></td>
        <td><b>SB</b></td>
  </tr>
  </tr>
        <td></td>
        <td align="right"><b>Subject Code</b></td>
        <td><b>MCA 202</b></td>
        <td><b>MCA 204</b></td>
        <td><b>MCA 206</b></td>
        <td><b>MCA 208</b></td>
        <td><b>MCA 210</b></td>
  </tr>
  <tr>
        <td>1.</td>
        <td>ontact forms are one of the most common elements found on a web page, and they can be used to gather just about any type of information required from your users.</td>
        <td align="center">
            <label>
                <input type="radio" name="jsq1">1
            </label>
            <label>
                <input type="radio" name="jsq1">2
            </label></br>
            <label>
                <input type="radio" name="jsq1">3
            </label>
            <label>
                <input type="radio" name="jsq1">4
            </label></br>
            <label>
                <input type="radio" name="jsq1">5
            </label>
       </td>

       <td align="center">
            <label>
                <input type="radio" name="atq1">1
            </label>
            <label>
                <input type="radio" name="atq1">2
            </label></br>
            <label>
                <input type="radio" name="atq1">3
            </label>
            <label>
                <input type="radio" name="atq1">4
            </label></br>
            <label>
                <input type="radio" name="atq1">5
            </label>
       </td>

       <td align="center">
            <label>
                <input type="radio" name="gkq1">1
            </label>
            <label>
                <input type="radio" name="gkq1">2
            </label></br>
            <label>
                <input type="radio" name="gkq1">3
            </label>
            <label>
                <input type="radio" name="gkq1">4
            </label></br>
            <label>
                <input type="radio" name="gkq1">5
            </label>
       </td>

       <td align="center">
            <label>
                <input type="radio" name="psq1">1
            </label>
            <label>
                <input type="radio" name="psq1">2
            </label></br>
            <label>
                <input type="radio" name="psq1">3
            </label>
            <label>
                <input type="radio" name="psq1">4
            </label></br>
            <label>
                <input type="radio" name="psq1">5
            </label>
       </td>

       <td align="center">
            <label>
                <input type="radio" name="sbq1">1
            </label>
            <label>
                <input type="radio" name="sbq1">2
            </label></br>
            <label>
                <input type="radio" name="sbq1">3
            </label>
            <label>
                <input type="radio" name="sbq1">4
            </label></br>
            <label>
                <input type="radio" name="sbq1">5
            </label>
       </td>
  </tr>
</table>
</form>

AddDetails.php AddDetails.php

<?php

    $jsq1 = $_POST['jsq1'];
    echo "$jsq1";

    $atq1 = $_POST['atq1'];
    echo "$atq1";
?>

I want to get values of radio button and add to mysql but this is showing out put 我想获取单选按钮的值并添加到mysql,但这显示出来

onon

How to get values like 1,2,3,4 and 5 that can I add into the database. 如何获取可以添加到数据库中的1,2,3,4和5之类的值。

You must have to write value attribute 您必须写value属性

<input type="radio" name="sbq1" value="3">

so when form is submitted, 3 will be submitted to server 因此,在提交表单时,会将3提交给服务器

As said, you need to add a value attribute: 如前所述,您需要添加一个value属性:

<input type="radio" name="sbq1" value="1">1

value is the actual value that will be submitted. value是将要提交的实际值。


You can use this to automatically add the value attribute: 您可以使用它来自动添加value属性:

 $('input[type=radio]').each(function () { $(this).attr('value', $(this).parent().text()); }); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM