is there any way to get the radio button value by using ajax code. already i have used jquery.i have a five radio buttons with five different values.. how do i make it by ajax. how to give the name in data url. button NAME=code
.. need some example. `
..$.ajax({
type: "POST",
url: "include/make.php", `
can any one tell me clearly
thanks nancy
function getData(check_val)
{
if(window.XMLHttpRequest)
{
XMLHttpRequestObject = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
//alert("hi");
if(XMLHttpRequestObject)
{
XMLHttpRequestObject.open("POST", 'include/make.php');
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
{
//document.getElementById(divID).innerHTML="";
XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null);
}
}
It's not entirely clear what you're asking, but for instance if you're trying to trigger the ajax call when the button is clicked:
$("input[type=radio][name=xyz]").click(function() {
$.ajax({
type: "POST",
url: "include/make.php",
data: {name: this.value}
});
});
...will call make.php
with a name
field set to the value
property of the radio button that was clicked. Above I've used the name "xyz" for the radio buttons, but obviously switch that to be whatever their actual name is. You said you wanted to send the name of the radio button, but I've assumed you wanted its value, since of course the name wouldn't vary in the above (it would always be "xyz").
If you really want its name, I assume you'll be hooking the event on more radio buttons. This example hooks all radio buttons on the page, and sends their name
and value
to make.php
:
$("input[type=radio]").click(function() {
$.ajax({
type: "POST",
url: "include/make.php",
data: {name: this.name, value: this.value}
});
});
Maybe it will help (your question is not clear)
$.ajax({
type: "POST",
url: "include/make.php",
data: "myval1=" + $("#myradiobtn1").val() + "&myval2=" + $("#myradiobtn2").val()
});
If you have a form you can use for example jQuery's serializeobject plugin to mine out data from a form.