HTML:
<form id="radio_form">
<fieldset>
<label><input class="myRadio" type="radio" name="color" value="1" checked="checked" />1</label><br />
<label><input class="myRadio" type="radio" name="color" value="2" />2</label><br />
<label><input class="myRadio" type="radio" name="color" value="3" />3</label><br />
<label><input class="myRadio" type="radio" name="color" value="4" />4</label><br />
<label><input class="myRadio" type="radio" name="color" value="5" />5</label><br />
</fieldset>
</form>
<br />
<br />
<img class="CanVote" src="myImage78007.png" alt="myImage78007">
JavaScript (jQuery):
var gFileToPostTo='VoteImage.aspx'; //Location of the file you want to send the POST Request to
function VoteImage(pVote,pImage) {
$.post(gFileToPostTo, { vote: pVote, image: pImage} ); //We send POST reuqest to the file, which is set above
}
$(document).ready(function(){
$('img .CanVote').click(function() { //if the client, click on one of the image so have class "CanVote"....
VoteImage(1,$(this).src); // Will it send a POST request to the file that is set above, with a vote 1
});
$('.myRadio').click(function() { //If the client , click on one of the radio buttons ..
var vote = $(this).val();
$('img .CanVote').each(function(i) {
VoteImage(vote,$(this).src); //Will the vote be sent as POST to the file that has been set above. With the vote they chose to all the images. This is repeated for all images on the page that has CanVote class
});
}
}
For more information on POST in jQuery:
http://api.jquery.com/jQuery.post/