Note that there are some explanatory texts on larger screens.

plurals
  1. POClick event is just refreshing the page?
    text
    copied!<p>I am a little lost trying to sort out this bug and please bare with me. When I click the 'Submit' button the page just seems to refresh and no messages are displayed that are suppose to read either 'Completed' or 'Not'. I added was some Ajax functions to populate some drop down list dynamically for information from MySQL database. </p> <p>Question: <em>Why is my page not submitting, it is just 'refreshing'?</em> (after adding the Ajax function and populating drop down list from php file)</p> <pre><code>&lt;SCRIPT type="text/javascript"&gt; function populatematerial(str) { if (window.XMLHttpRequest) { // IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getmaterial.php?q="+str,true); xmlhttp.send(); } </code></pre> <p></p> <pre><code>&lt;form name='form1' method="POST" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt; &lt;table border="0" width="100%" id="table1"&gt; &lt;tr&gt; &lt;td width="144"&gt;DB Username&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="dbusername" size="32"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="144"&gt;DB Password&lt;/td&gt; &lt;td&gt;&lt;input type="password" name="dbpassword" size="32"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="144"&gt;Tank Type&lt;/td&gt; &lt;td&gt;&lt;select name="tanktype" id="tools" onChange="populatematerial(this.value)"&gt; &lt;option&gt;&lt;/option&gt; &lt;option value="Metal"&gt;Metal&lt;/option&gt; &lt;option value="Rinse"&gt;Rinse&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="material_show" style="display:none;"&gt; &lt;td width='144'&gt;Material&lt;/td&gt; &lt;td&gt; &lt;select size='1' name='material' id="txtHint"&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;input type="submit" value="Submit" name="result" &gt;&lt;/p&gt; </code></pre> <p></p> <pre><code> &lt;?php if (isset($_POST['result'])) { session_start(); // check user id and password if (!authorized($dbuser1,'#####')) { echo "&lt;h2&gt;You are not authorized. Sorry.&lt;/h2&gt;"; // exit to different page } // open database connection // upload some data via $submitquery mysql_query($submitquery) or die('UNABLE TO SUBMIT DATA'); echo "&lt;b&gt;Submit Successful&lt;/b&gt;&lt;p&gt;"; // close database connection ?&gt; </code></pre> <p>PHP file that populates material dropdown:</p> <pre><code>&lt;?php $q=$_GET["q"]; // open database connection $query = "select * from r2rtool.platingmaterialtype where type = '".$q."'"; $result = mysql_query($query); $option = ""; while($row = mysql_fetch_array($result)) { $option.="&lt;option value=\"{$row['Material']}\"&gt;{$row['Material']}&lt;/option&gt;"; } echo "&lt;option value='0'&gt;&lt;/option&gt;"; echo $option; // close database connection ?&gt; </code></pre>
 

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