php - When Requesting a page from ajax and submiting the form that requested page shows nothing['Solved'] -


i have 4 options single,multiple, matrix , true false kinds of question having value 1-4 respectively in addquestions.php.now have requesting page through id using ajax using method , in requested page have given condition if id ==1 include file singlequestion.php , on.now problem has been arises in singlequestion.php, there 4 options radio buttons. when ajax request files shows contents of singlequestion.php, whenever submitting form in addquestions.php not retrieving value of singlequestion.php inputs. below code:- addquestions.php

<form action="insertquestion.php" method="post">    <select name="selectquestiontype" class="questioninput" onchange='showuser(this.value)' id="selectquestiontype">            <option value="0" selected>select question type</option>            <option value="1">single choice </option>            <option value="2">multiple choice question</option>            <option value="3">fill in blanks</option>            <option value="4">true false</option>            <option value="5">match matrix</option>       </select> <input type="submit" class="button add" value="save" style="width:auto;" id="addsave" name="myaddsave">                   <input type="submit" class="button add" value="save & next" style="width:auto;" id="savenext" name="mynextsave">  <script type="text/javascript"> 

`

        function showuser(str)         {                 if (str=="")                        {                         document.getelementbyid("txthint").innerhtml="";                           return;                         }                  if (window.xmlhttprequest)                     {   // code ie7+, firefox, chrome, opera, safari                           xmlhttp=new xmlhttprequest();                     }                   else                     {   // code ie6, ie5                         xmlhttp=new activexobject("microsoft.xmlhttp");                     }                        xmlhttp.onreadystatechange=function()                     {                     if (xmlhttp.readystate==4 && xmlhttp.status==200)                       {                       document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext;                       }                     }                         xmlhttp.open("get","getquestions.php?q="+str,false);                         xmlhttp.send();                     }                                </script>                     <div id="txthint"><b>question mode displayed here!.</b></div>                     <input type="submit" class="button add" value="save" style="width:auto;" id="addsave" name="myaddsave">                     <input type="submit" class="button add" value="save & next" style="width:auto;" id="savenext" name="mynextsave">                     ` 

getquestions.php

    <?php   $q=$_get["q"]; if($q==1) {     include 'singlequestion.php'; } else if($q == 2)    {         include 'multiplequestion.php';    }  else if($q == 3)   {     include 'fillquestion.php';   }    else if($q == 4)  {     include 'truequestion.php';  } else if($q == 5)  {      include 'matchquestion.php';  }  else    {         echo 'you have not selected question type yet!';   }   ?> 

in singlequestion.php

<style type="text/css"> .javascript { display: none; } </style> <?php     echo $answer1 = $_post['answer1'];          echo $answer2 = $_post['answer2']; ?> <br> <div class="singlecontainer">  <div class="jdradio"> <div class="jdraone">     <span class="answer">a</span><br><br>     <span class="jdanswer"><input type="radio" name="a1"></span> </div> <div id="hide1" class="jdtext">     <input type="text" name="answer1" style="width:600px;padding:7px;"  > </div> </div>      <br><br><div class="jdradio"> <div class="jdraone">     <span class="answer">b</span><br><br>     <span class="jdanswer"><input type="radio" name="a1" ></span> </div> <div id="hide2" class="jdtext">     <input type="text" name="answer2" style="width:600px;padding:7px;" value="joydseep" > </div> </div>      <br><br><div class="jdradio"> <div class="jdraone">     <span class="answer">c</span><br><br>     <span class="jdanswer"><input type="radio" name="a1"></span> </div> <div id="hide3" class="jdtext">     <input type="text" name="answer3" style="width:600px;padding:7px;" > </div> </div>      <br><br><div class="jdradio"> <div class="jdraone">     <span class="answer">d</span><br><br>     <span class="jdanswer"><input type="radio" name="a1"></span> </div> <div id="hide4" class="jdtext">     <input type="text" name="answer4" style="width:600px;padding:7px;"  > </div> </div> <div id='textboxesgroup'>     <div id="textboxdiv1">         <label style="color:#f1f1f1;">textbox #1 : </label>     </div> </div> <br> <div class="javascript">your script data executed. </div>  <input type="submit" name="jdb"> </form>  </div> 

insertquestion.php

<?php echo $answer1 = $_post['answer1'];          echo $answer2 = $_post['answer2']; ?> 

above codes, i'm newbie in ajax stuffs don't know ajax that's why got stucked.any appreciated much

modify singlequestion.php according

<?php if(isset($_post['jdb'])){     echo $answer1 = $_post['answer1'];          echo $answer2 = $_post['answer2']; } else{ ?> <br> <div class="singlecontainer"> <form name="form1" action="" method="post"> <div class="jdradio"> <div class="jdraone">     <span class="answer">a</span><br><br>     <span class="jdanswer"><input type="radio" name="a1"></span> </div> <div id="hide1" class="jdtext">     <input type="text" name="answer1" style="width:600px;padding:7px;"  > </div> </div>  <br><br><div class="jdradio"> <div class="jdraone">     <span class="answer">b</span><br><br>     <span class="jdanswer"><input type="radio" name="a1" ></span> </div> <div id="hide2" class="jdtext">     <input type="text" name="answer2" style="width:600px;padding:7px;" value="joydseep" > </div> </div>      <br><br><div class="jdradio"> <div class="jdraone">     <span class="answer">c</span><br><br>     <span class="jdanswer"><input type="radio" name="a1"></span> </div> <div id="hide3" class="jdtext">     <input type="text" name="answer3" style="width:600px;padding:7px;" > </div> </div>      <br><br><div class="jdradio"> <div class="jdraone">     <span class="answer">d</span><br><br>     <span class="jdanswer"><input type="radio" name="a1"></span> </div> <div id="hide4" class="jdtext">     <input type="text" name="answer4" style="width:600px;padding:7px;"  > </div> </div> <div id='textboxesgroup'>     <div id="textboxdiv1">         <label style="color:#f1f1f1;">textbox #1 : </label>     </div> </div> <br> <div class="javascript">your script data executed. </div>  <input type="submit" name="jdb"> </form> <?php }?> 

in code missed form starting tag


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -