php - ajax value fetched but unable to store -


when select in bill.php, ajax call , value user.php display content on bill.php page how hold value in variable in bill.php page further use in php

<?php include('db.php'); ?> <html> <head> <style> table, tr th{     border: green; }  th {  } </style>   <script type="text/javascript"> function updatesum() { document.form.sum.value =  (document.form.sum2.value -0); document.form.sumone.value = (document.form.sum3.value -0) ; document.form.sumtotal.value = (document.form.sum.value -0) * (document.form.sumone.value -0); document.form.sumtotalgiven.value=(document.form.sumtotalmoney.value -0) - (document.form.sumtotal.value -0);  } </script> <script> function showuser(str) {     if (str == "") {         document.getelementbyid("txthint").innerhtml = "";          //document.getelementbyid("txthin").innerhtml = "";         return;     } else {          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;                 //document.getelementbyid("txthin").innerhtml = xmlhttp.responsetext;             }         }         xmlhttp.open("get","getuser.php?q="+str,true);         xmlhttp.send();     } } </script> <script> function shouser(str) {     if (str == "") {         document.getelementbyid("txthin").innerhtml = "";         return;     } else {          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("txthin").innerhtml = xmlhttp.responsetext;             }         }         xmlhttp.open("get","getuser.php?q="+str,true);         xmlhttp.send();     } } </script> </head> <body bgcolor="#c7cbe1"> <form method="get" name="form"> <table border="0" bordercolor="#d83e41">        <tr>                           <td>&nbsp;&nbsp;&nbsp;&nbsp; medicine &nbsp;&nbsp;&nbsp;&nbsp; </td>               <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; price&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   batchno              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expire date</td>              <td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                 quantity</td>                <td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                total </td>                              </tr>    <tr>                        <td>                         <?php                             $qry="select * inventory";                             $rs=mysql_query($qry);                         ?>                         <select name="user" onchange="showuser(this.value)">                             <option value=>selet medicine name</option>                           <?php                             while($rw=mysql_fetch_array($rs)){                          ?>                             <option value="<?php echo $rw['id']?>"><?php echo $rw['medicine']?></option>                             <?php                              }                         ?>                         </select>                  </td>                <td>                   <div id="txthint">                           </div>                </td>                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                 <input type="text" name="sum2" style="width: 70px" onchange="updatesum()" ></td>               <td>              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;               <input name="sum" readonly " style="width: 70px"></td>    </tr> <tr>                        <td>                         <?php                             $qry="select * inventory";                             $rs=mysql_query($qry);                         ?>                         <select name="user" onchange="shouser(this.value)">                             <option value=>selet medicine name</option>                           <?php                             while($rw=mysql_fetch_array($rs)){                          ?>                             <option value="<?php echo $rw['id']?>"><?php echo $rw['medicine']?></option>                             <?php                              }                         ?>                         </select>                  </td>                <td>                   <div id="txthin">                           </div>                </td>                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                 <input type="text" name="sum3" style="width: 70px" onchange="updatesum()" ></td>               <td>              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;               <input name="sumone" readonly " style="width: 70px"></td>              <td>  </td> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> </tr>   <tr> <td></td> <td></td> <td></td> <td>                  total<input name="sumtotal" readonly style="border:0px;"> </td> </tr>   <tr> <td></td> <td></td> <td></td> <td>                   paid<input type="text" name="sumtotalmoney" style="border:0px;" onchange="updatesum()"> </td> </tr> <tr> <td></td> <td></td> <td></td> <td>                 return<input name="sumtotalgiven" readonly style="border:0px;" > </td> </tr>                           </table> </form>    <br>   </body> </html>             <?php include("db.php"); ?> <!doctype html> <html> <head> <style> table {     border-collapse: collapse; }  table, td, th {    /* border: 1px solid black;*/    /* padding: 5px;*/    text-align: center; }  th {text-align: left;} </style>  <body>  <?php $q = intval($_get['q']);  //echo $q;     $qry="select * inventory id = '".$q."'"; $rs=mysql_query($qry); ?>    <?php while($rw=mysql_fetch_array($rs)){ ?> <table> <tr> <td> <?php echo "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp" . "&nbsp". "&nbsp". "&nbsp" ?>  <?php  echo $rw['price']?> <?php echo "&nbsp". "&nbsp" . "&nbsp" . "&nbsp" . "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp" . "&nbsp". "&nbsp". "&nbsp" ?>  <?php echo $rw['batchno'] ?>   <?php echo "&nbsp". "&nbsp" . "&nbsp" . "&nbsp" . "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp". "&nbsp" . "&nbsp". "&nbsp". "&nbsp" ?>   <?php echo $rw['expire'] ?>   </td>   </tr> </table>         <?php  } ?>    </body> </html> 

read more sessions in php.

if need store values between php files can like:

<?php session_start();  $_session['myvariable'] = $_get['myvariable']; 

in php file can previous defined variable as:

<?php session_start();  echo $_session['myvariable']; 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -