anushka Posted September 22, 2008 Share Posted September 22, 2008 hi every one i want to create a radio button and by using on click i want the event to be occurred i wrote the code but its not working.Can any one help me Radio.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="radio.js"> </script> </head> <body> <form name="form" action="radio.php" method="POST"/> Yes:<input type="radio" value="yes" name="radio1" onclick="showRequest(this.form,"radio.php")"/> NO<input type="radio" value="no" name="radio1" onclick="showRequest(this.form,"radio.php")"/> </form> <div id="radio"></div> </body> </html> and my js file var xmlHttp function showResult(str) { document.getElementById("radio").InnerHTML=""; return } xmlHttp=GetXmlHttpObject() if(xmlHttp==null) { alert("Browser dosent support Ajax"); return } var url="radio.php" //url=url+?"$q="+str xmlHttp.onreadystatechanged=stateChanged xml.open("GET",url,true) xmlHttp.send(null); function stateChanged() { if(xmlHttp.steadystate==4||xmlHttp.steadystate="complete") { document.getElementById("radio").innerHTML=xmlHttp.responseText(); document.getElementById("radio"). style.border="1px solid #A5ACB2"; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } .php file <?php $q=$_GET["q"]; echo $q; $radio=$_POST['radio1']; if($radio=="yes") { echo yes; ?> <input type="text" name="text"/> <?php } else{ echo no; ?> <input type="submit" value="click"/> <?php } ?> if there are please Reply 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.