Manipulate table background colour based on SQL with parameter was table value

alil

New Member
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:\[code\]<script> function setvalue(values) { document.getElementById('posisi').value = http://stackoverflow.com/questions/15784210/values; }</script>\[/code\]HTML of my table:\[code\]<table width="1023" height="248" border="1"> <tr> <th colspan="2" scope="col">A1</th> <th colspan="2" scope="col">A2</th> <th colspan="2" scope="col">A3</th></tr><tr> <td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="http://stackoverflow.com/questions/15784210/A1.4" /></td> <td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="http://stackoverflow.com/questions/15784210/A1.8" /></td> <td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="http://stackoverflow.com/questions/15784210/A2.4" /></td> <td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="http://stackoverflow.com/questions/15784210/A2.8" /></td> <td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="http://stackoverflow.com/questions/15784210/A3.4" /></td> <td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });setvalue(this.value);" value="http://stackoverflow.com/questions/15784210/A3.8" /></td></tr></table>\[/code\]I try to manipulate background colour with this JavaScript:\[code\]<script type="text/javascript">var htmlobjek;$(document).ready(function(){ var pid = "document.getElementById('posisi').value = http://stackoverflow.com/questions/15784210/values"; $.ajax({ url: "cek.php", data: "pid="+posisi, cache: false, success: function(data) {\[/code\]My algorithm when my SQL success in cek.php I will call back and display in current page to manipulate the table background colour. In cek.php my SQL like this:\[code\]SELECT ..FROM..WHERE posisi='S_POST[posisi]'\[/code\]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.
 
Back
Top