Reputation: 1253
What's wrong with the code of radio button? When I've tried SELECT/OPTION it's working.
I'm trying to make two groups of radio button, get their values and sum up. but I can't move through since the radio buttons don't make response at all.
These are inputs to my form:
<input type='radio' id='1' name='r' onclick='pieces('this.value')'
autocomplete='off' value='yes'>Yes
<input type='radio' id='2' name='r' onclick='pieces('this.value')'
autocomplete='off' value='no'>No
My script:
<script type='text/javascript'>
function pieces(str)
{
if (str=='')
{
document.getElementById(abc).innerHTML='';
return;
}
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{
// code for IE6, IE5
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(abc).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open('GET','price.php?q='+str,true);
xmlhttp.send();
}
</script>
Upvotes: 2
Views: 2231
Reputation: 512
Here is the modified script. Inputs:
<input type='radio' id='1' name='r' onclick="pieces(this.value);"
autocomplete='off' value='yes'>Yes
<input type='radio' id='2' name='r' onclick="pieces(this.value);"
autocomplete='off' value='no'>No
Here is the js script:
function pieces(str)
{
if (str=='')
{
document.getElementById("abc").innerHTML='Choose something';
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("abc").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open('GET','hey.php?q='+str,true);
xmlhttp.send();
}
Let me know if any prob.
Jasminder
Upvotes: 2