Submit radio buttons selection

I have this code for a radio-button poll:

<div id="MyPoll">
How was the game?<br />
<form id="FirstPoll">
<input type="radio" name="Poll1" value="x" onclick="GetVote(this.value)" /> Awesome<br />
<input type="radio" name="Poll1" value="y" onclick="GetVote(this.value)" /> Awful<br />
<input type="submit" value="Submit">

where the "GetVote" function is this:

function GetVote(int) {
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else  {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    document.getElementById("MyPoll").innerHTML=xmlhttp.responseText; }
xmlhttp.send(); }

In this way, when a user votes, the result directly shows, but I want the user vote to pass to a SUBMIT button before it shows. I guess that I have to insert document.getElementById("FirstPoll").submit(); somewhere in my "GetVote" function (....where?), get rid of the 'onclick' events from the 'input' and trigger the "GetVote" function with a submit button? Any suggestion is more than appreciate!



Trigger the submission from the onsubmit handler:

<form id="FirstPoll" onsubmit="GetVote(this); return false;">

function GetVote(form) {
    var int = form.Poll1.value;
    // Code to submit via AJAX

Need Your Help

Differences between C++11, C# and Java memory models

java c++ multithreading memory-management c++11

I know that C++11 memory model was inspired from Java memory model, but there has to be something that differentiates both these memory models.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.