Jump to content

i want to create a radio button using ajax and onclickevent should be generated


anushka

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.