i am trying to pass value through the following code, but unable please anyone check maybe i am mistaking somewhere
<input type="button" name="vote" value="Yes" width="100" onclick="getVote('; echo "y".$info['autoid']; echo')"/>
the problem is in following line “y”.$info[‘autoid’]; if i remove “y”. its works fine. but i want to pass y and product id.
basically i am trying to joint the y with the int.
ok here is full code.
<script type="text/javascript">
function getVote(int)
{
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("poll").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","../poll/"+int,true);
xmlhttp.send();
}
</script>
<div id="poll">
<form>
poll - :
<input type="button" name="vote" value="Yes" width="100" onclick="getVote('; echo "y".$info['autoid']; echo')"/>
<input type="button" name="vote" value="No" width="100" onclick="getVote('; echo "n".$info['autoid']; echo')"/>
</form>
</div>
thanks guys…i found the other way we can pass “-” for yes and empty for “n”
<input type="button" name="vote" value="Yes" width="100" onclick="getVote('; echo "-".$info['autoid']; echo')"/>
<input type="button" name="vote" value="No" width="100" onclick="getVote('; echo $info['autoid']; echo')"/>
int is a reserved word in javascript, also you should use something like JQuery to handle your ajax-calls.