FrankieGee Posted June 10, 2013 Share Posted June 10, 2013 I am trying to accomplish a table to be filled with selections from a database using php and javascript. My javascript code is: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.js'></script> <script type="text/javascript"> $(window).load(function(){ $(document).ready(function() { $("input[type=checkbox]").click(function() { if ($(this).is(':checked')) $('#textbx1').html($('#textbx1').val() + $(this).attr('name') + "\n"); else { var text = $('#textbx1').val(); text = text.replace($(this).attr('name') + "\n" ,""); $('#textbx1').html(text); } }); }) }); </script> and my table code is: echo "<input type=\"checkbox\" rel=\"textbox\" name=\"$item_no\">$item_no</input><br />"; } echo "<br />"; echo ""; echo "</table>"; echo "</table>"; echo "<table border ='0' width='100%'><tr><td align='center'><strong><font size='4'><font color='#008301'>Quoted Items</font></strong></td></tr></table>"; echo "<table border ='1' width='100%'>"; echo "<th>Item ID</th>"; echo "<th>Description</th>"; echo "<th>QTY</th>"; echo "<th>Sell Price</th>"; echo "<th>Cost</th>"; echo "<th>Prft%</th>"; echo "<th>Prft$</th></tr>"; /* while (odbc_fetch_row($rs)) { $cscode=odbc_result($rs,"cscode"); $csname=odbc_result($rs,"csname"); $item_no=odbc_result($rs,"item_no"); $order_date=odbc_result($rs,"order_date"); $order_date2 = date( "m-d-Y", strtotime( $order_date ) );*/ echo "<tr><td><text id=\"textbx1\" \"r\"\"n\"></text></td>"; echo"<td>$ </td>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td> </td></tr>"; //} // odbc_close($conn); echo "</table>"; This Javascript is populating in one cell of the table, but will not show new (or next) item in a new cell. It overwrites the first cell.Any ideas? Thank you for looking. Link to comment https://forums.phpfreaks.com/topic/278992-populate-table-with-javascript-with-multiple-lines/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.