Note that there are some explanatory texts on larger screens.

plurals
  1. POManipulate table background colour based on SQL with parameter was table value
    text
    copied!<p>I am trying to develop my website. There is a table that I made in as a button. I get the value of the button with JavaScript like this:</p> <pre><code>&lt;script&gt; function setvalue(values) { document.getElementById('posisi').value = values; } &lt;/script&gt; </code></pre> <p>HTML of my table:</p> <pre><code>&lt;table width="1023" height="248" border="1"&gt; &lt;tr&gt; &lt;th colspan="2" scope="col"&gt;A1&lt;/th&gt; &lt;th colspan="2" scope="col"&gt;A2&lt;/th&gt; &lt;th colspan="2" scope="col"&gt;A3&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="A1.4" /&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="A1.8" /&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="A2.4" /&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="A2.8" /&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="A3.4" /&gt;&lt;/td&gt; &lt;td&gt;&lt;div align="center"&gt;&lt;input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="A3.8" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I try to manipulate background colour with this JavaScript:</p> <pre><code>&lt;script type="text/javascript"&gt; var htmlobjek; $(document).ready(function(){ var pid = "document.getElementById('posisi').value = values"; $.ajax({ url: "cek.php", data: "pid="+posisi, cache: false, success: function(data) { </code></pre> <p>My algorithm when my SQL success in cek.php I will call back and display in current page to manipulate the table background colour. </p> <p>In cek.php my SQL like this:</p> <pre><code>SELECT .. FROM.. WHERE posisi='S_POST[posisi]' </code></pre> <p>I will count the result (use this <code>mssql_num_row(sql)</code>). If the result has a value, the background colour of the table will be red. If not, it will be green. This is what makes me confused. Any idea for my website? I hope you understand what I mean.</p>
 

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