bindiya Posted April 20, 2011 Share Posted April 20, 2011 This topic was pasted in php forum becoz i didnt know this comes in ajax also. When i got the reply to post in ajax forum, i am posting my problem in ajax forum.Sorry for the double post. SORRY. In my php page ,the 5 datas are taken from the database table. 3 among them are displayed in a radio button value,and one is displayed as a value in the input field of type hidden . I need to pass these hidden value along with the selected radio button value to the ajax script Is it possible to do this $q="select * from questions where id=(select max(id) from questions)"; $r=mysql_query($q); $row=mysql_fetch_row($r); $poll_id = $row['id']; $question=$row['question']; [color=red]echo "<input type='hidden' name='question' id='question' value=$question>";[/color]//this value is the one to be passed to ajax function echo "<tr><td>$row[1]</td></tr>". "<tr><td><input type='radio' value='1' name='answer' id='answer' onclick='getVote(this.value)'>$row[2]</td></tr>". "<tr><td><input type='radio' value='2' name='answer' id='answer' onclick='getVote(this.value)'>$row[3]</td></tr>". "<tr><td><input type='radio' value='3' name='answer' id='answer' onclick='getVote(this.value)'>$row[4]</td></tr>". "<tr><td><input type='radio' value='4' name='answer' id='answer' onclick='getVote(this.value)'>$row[5]</td></tr>". "</table>"; ------------ajax function function getVote(int) { var quest= document.getElementById['question'].value ; //alert(quest); var params = "vote=int&q=quest"; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5& +"&question="+q xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("poll").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","abc.php? "+params,true); xmlhttp.send(); } Quote Link to comment Share on other sites More sharing options...
sunfighter Posted April 20, 2011 Share Posted April 20, 2011 Since $question has a unique value and your writing the page in php why not just add it to the params value: var params = "vote=int&q="+<?php echo $question ?>; think that's where it goes. Or just run a query for it in abc.php. Quote Link to comment Share on other sites More sharing options...
bindiya Posted April 21, 2011 Author Share Posted April 21, 2011 thanks for the idea.It got solved.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.