Jump to content

Populate table with Javascript with multiple lines


FrankieGee

Recommended Posts

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.

Edited by FrankieGee
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.