1

i have been trying to find my way around this issue, I have used

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

but all that does is redirect me to the page, I want to have a radio button that is selected redirect me to a page and then submit the form data to the div on that page and that page only, heres the form

 <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>

and heres the div where we $_GET the data from the form and post it in the 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>

I have been stuck on this issue for a day, and I can't get out, please help!

if it's TL; DR I want to be able to have one radio option selected, and when the user presses submit I want them to be redirected to the page of the radio option and then i want the data to be posted there and no where else. Please help! Thanks in advance -Connor

1 Answers1

0

You are redirecting but not including the posted data.

It sounds like you should create a hidden form that the users don't see, and when they submit the form you have now, dynamically fill in the needed inputs and then trigger that form, posting the data to the correct page.

See the second answer here: pass post data with window.location.href

Community
  • 1
  • 1
Andrew
  • 18,680
  • 13
  • 103
  • 118
  • Do I have to hide the form though? I need it to be there for the user to fill in, or I might be misunderstanding, but I think that you have the answer I am looking for otherwise. Thanks! -Connor – user3630438 May 20 '14 at 05:21
  • You have the form for the user to fill in, but you have a second form that is hidden that you populate with the data from the form the user submits, including the correct action and method, then use jquery to submit that form – Andrew May 20 '14 at 05:32