Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.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 如何以选项卡形式发送多个单选按钮值_Javascript_Php_Jquery_Html_Css - Fatal编程技术网

Javascript 如何以选项卡形式发送多个单选按钮值

Javascript 如何以选项卡形式发送多个单选按钮值,javascript,php,jquery,html,css,Javascript,Php,Jquery,Html,Css,HTML: <div class="tab"><h4>Zip Code</h4> <p><input type="text" class="text1" placeholder="Enter zip code..." oninput="this.className = ''" name="zipcode"></p> </div> <div class="tab"><h4>Q

HTML:

<div class="tab"><h4>Zip Code</h4>
    <p><input type="text" class="text1" placeholder="Enter zip code..." oninput="this.className = ''" name="zipcode"></p>
  </div>
  <div class="tab"><h4>Question1</h4>
    <p><input type="radio" name="rdb" value="1-3 months"  class="option-input radio" checked/> 1-3 months</p>
    <p><input type="radio" name="rdb" value="4-6 months" class="option-input radio"> 4-6 months</p>
  </div>

  <div class="tab"><h4>Question2</h4>
    <p><input type="radio" name="rdb1" value="Single" class="option-input radio"  checked/> Single</p>
    <p><input type="radio" name="rdb1" value="Condo" class="option-input radio"> condo</p>
    <p><input type="radio" name="rdb1" value="Mobile" class="option-input radio">Mobile</p>
  </div>

  <div class="tab"><h4>Question3</h4>
    <p><input type="radio" name="rdb2" value="Moving" class="option-input radio" checked/> Moving</p>
    <p><input type="radio" name="rdb2" value="100" class="option-input radio"> 100</p>
  </div>

  <button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
  <button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
查询如下: 我在HTML中使用多制表符表单,并使用javascript和PHP将所有值发送到电子邮件。请检查上面的代码

我收到这封电子邮件:

Zipcode: 问题1: 问题2: 问题3:

第一部分是HTML代码,第二部分是Javascript,第三部分是Php代码

//Html
//Html 
<form method="post" id="submit">
    Your html code goes here 
    <input type="button" onclick="onclick()" value="submit">
</form>

//javascript
function onclick()
{

$.ajax({type:'POST', url: 'email.php', data:$('#submit').serialize(), success: function(response) {
    alert(response); //success or fail from email.php page
}});

}

//php email.php
echo "<pre>";print_r($_POST); //here u can see all submitted data from html
你的html代码在这里 //javascript 函数onclick() { $.ajax({type:'POST',url:'email.php',data:$('#submit')).serialize(),success:function(response){ 警报(响应);//email.php页面中的成功或失败 }}); } //php email.php 回声“;打印(邮政美元)//在这里你可以看到所有提交的数据从html
使用
文档.querySelector('input[name=rdb]:checked')。值从单选按钮获取所选值

功能测试(){
var rdb=document.querySelector('input[name=rdb]:checked')。值;
var rdb1=document.querySelector('input[name=rdb1]:checked')。值;
var rdb2=document.querySelector('input[name=rdb2]:checked')。值;
日志(rdb、rdb1、rdb2);
}
.tab{
宽度:30%;
浮动:左;
}

问题1
1-3个月

4-6个月

问题2 单身

公寓

流动的

问题3 移动的

一百

试验
…您试过这个吗?发生了什么事?是的,我试过了,但没有得到电子邮件中单选按钮的值
$EmailFrom = "test@gmail.com";
$EmailTo = "xyz@gmail.com";
$Subject = "Test";

$zipcode = $_POST['zipcode'];
$rdb_value = trim(stripslashes($_POST['rdb']));
$rdb_value1 = trim(stripslashes($_POST['rdb1']));
$rdb_value2 = trim(stripslashes($_POST['rdb2']));

$Body .= $zipcode;
$Body .= "Question1: ";
$Body .= $rdb_value;
$Body .= "Question2: ";
$Body .= $rdb_value1;
$Body .= "Question3: ";
$Body .= $rdb_value2;
//Html 
<form method="post" id="submit">
    Your html code goes here 
    <input type="button" onclick="onclick()" value="submit">
</form>

//javascript
function onclick()
{

$.ajax({type:'POST', url: 'email.php', data:$('#submit').serialize(), success: function(response) {
    alert(response); //success or fail from email.php page
}});

}

//php email.php
echo "<pre>";print_r($_POST); //here u can see all submitted data from html