Just solved a problem using Javascript onclick, can click on any cell in a dynamic table and it will pass the innerText object value to my form text field. parts of code given below:
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript">
- function select_cell(obj)
- {
- document.getElementById('complaint').value = obj.innerText;
- document.getElementById('selected_form');
- }
while ($comp_rec= mysql_fetch_arr ay($complaintTa ble))
{echo "<tr><td id = 'complaint' onclick='select _cell(this);'>" ; echo $comp_rec['complaint'];
echo "</td>";[/PHP]
[HTML]<table id = "MAINFORM">
<form id = "selected_f orm" name = "complaint_sett ings" method = "POST" action = "php_complaint_ mysql.php">
<td>
<table border = "3" bordercolor = "gold" bgcolor = "00008B">
<tr><td>
<p style = "color:gold">Co mplaint: <br>
<input type = "text" size = "50" maxlength = "50" name = "complaint" >
</td></tr><br>
<tr><td>
<input type = "submit" name = "submit_c" value = "submit"> <br>
<input type = "submit" name = "submit_c" value = "update"> <br>
<input type = "submit" name = "submit_c" value = "delete" onClick = "return confirm('Are you sure you want to delete record?')">[/HTML]
my problem now is how to pass along my primary key which is the unique id of each $comp_rec to my form as a hidden variable so i can pass $_POST['complaint'] to php_complaint_m ysql.php for update or delete. As it is now the table i use onclick only shows a single column(complain t) and even if i add another cell/column (id) the two cells are not carried and placed in separate fields on the same form. Any idea on populating form fields by clicking a row record with each attribute being passed to appropriate field? Attribute ID not presently on table. wish to keep hidden. But need to pass ID so i can use to update mysql.
thanks.