选择了广播选项,所以发布到此页面

时间:2014-05-20 02:43:07

标签: php jquery html

我一直试图找到解决这个问题的方法,我已经使用了

$(function(){
$('form').submit(function(event){
    event.preventDefault();
    window.location = $('input[type=radio]:checked').val();
});
});

但所有这一切都是将我重定向到页面,我希望有一个选中的单选按钮将我重定向到一个页面,然后将表单数据提交到该页面上的div和该页面,继承人表单< / p>

 <form name = "quoted" method="get">
 <input id = "poster" type="text" name="poster" required="required" placeholder = "Credited Individual.">     <br>
 <textarea class = "actual_quote" name = "actual_quote" required="required" placeholder = "Write the question here!"></textarea><br><br><br>
 <div class = "checkboxes" required="required">
<h3 style = "margin-top:-20px;">Please select one catagory that the quote falls into.</h3>
  <label for="x"><input type="radio" name="x" value="stupid.php" id = "x" checked="checked" />    <span>stupid</span></label><br>
    <label for="x"><input type="radio" name="x" value="stupider.php" id = "x" /> <span>stupider</span>    </label><br>
    <label for="x"><input type="radio" name="x" value="stupidest.php" id = "x"/>    <span>stupidest</span></label>
  </div>
  <input id = "submit1" type="submit"><br>
 </form>

并且继承了我们$ _GET表单中的数据并将其发布在div

中的div
 <div class="top-submit"><?php echo '&#8220;' . (!empty($_GET['actual_quote']) ?  $_GET['actual_quote'] : '') . '&#8221;'; $actual_quote = $_GET['actual_quote'];?>
 </div>
 <div class="poster"><?php echo "-" .  (!empty($_GET['poster']) ? $_GET['poster'] :''); $poster =  $_GET['poster'];?>
 <div class = "like">
 <a href = "javascript:countClicksLike();" class = "btn btn-large" style = "color:green;">Like</a>
 <p id = "like" style = "color:green;">0</p>
 </div>
 <div class = "dislike">
 <a href = "javascript:countClicks();" class = "btn btn-large" style = "float:right; color:red;">Dislike</a>
 <p id = "dis" style = "color:red;">0</p>
 </div>
  </div>
 <?php 
 "INSERT INTO submissions(top-submit, poster)
 VALUES ($actual_quote, $poster)";
?>
</div>
</div>

我被困在这个问题上一天,我无法离开,请帮助!

如果它是TL; DR 我希望能够选择一个无线电选项,当用户按下提交时,我希望将它们重定向到无线电选项的页面,然后我希望将数据发布到那里而不是其他地方。请帮忙!在此先感谢-Connor

1 个答案:

答案 0 :(得分:0)

您正在重定向但不包括发布的数据。

听起来你应该创建一个用户看不到的隐藏表单,当他们提交你现在拥有的表单时,动态填写所需的输入,然后触发该表单,将数据发布到正确的页。

请在此处查看第二个答案:pass post data with window.location.href