Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't do it by the way you tried.There are two better ways to do it</p> <ol> <li><p>Use <code>Ajax</code>.</p></li> <li><p>Use Cookies</p> <p>The best way here is to use Ajax. Here, iam using <code>javascript</code> and <code>ajax</code>.And i am creating a new file to create response(say newfile.php) Try this,</p> <p></p> <pre><code>function getCode(){ var v =document.forms["form1"]["part_code"].value; var x = document.forms["form1"]["part_code"].value; var y = document.forms["form1"]["location_code"].value; var z = document.forms["form1"]["date"].value; var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { var getPartCode=xmlhttp.responseText; //Getting the response from php file var a = (getPartCode + '/'+x +'/'+ y +'/'+ z); document.forms["form1"]["invent_code"].value = a; } } xmlhttp.open("GET","newFile.php?q="+v,true); //Sending request to newfile.php xmlhttp.send(); } &lt;/script&gt; </code></pre></li> </ol> <p><strong>newfile.php</strong> </p> <pre><code>&lt;?php $value = $_GET["q"]; //getting the value sent through tthe ajax request $query = mysql_query("SELECT COUNT(*)+1 as count FROM TB_TRANSACTION where part_code = '$value'"); $i=-1; while ($code_part = mysql_fetch_array($query)) { $i++; echo $code_part['count']; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload