ashleyfoozi Posted January 12, 2012 Share Posted January 12, 2012 Hi Everybody I need to place the result of the code automatically into a text box and not be displayed as an alert after a button press.This code can be found all over the net and all, with variations, end up with a button and an alert. I am collecting, using a repeating table, data that is alphanumeric. The end result must show automatically in a text box seperate from the table.Any help is appreciated. <html><head><script language="javascript"> function countTableRows() { var rows=document.getElementById("tbl").rows.length; alert(rows); }</script></head><body><table id="tbl"> <tr><td>Row 1</td></tr> <tr><td>Row 2</td></tr> <tr><td>Row 3</td></tr> <tr><td>Row 4</td></tr></table><input type="button" value="count" onClick="javascript:countTableRows()"></body></html><html><head><script language="javascript"> function countTableRows() { var rows=document.getElementById("tbl").rows.length; alert(rows); }</script></head><body><table id="tbl"> <tr><td>Row 1</td></tr> <tr><td>Row 2</td></tr> <tr><td>Row 3</td></tr> <tr><td>Row 4</td></tr></table><input type="button" value="count" onClick="javascript:countTableRows()"></body></html><html><head><script language="javascript"> function countTableRows() { var rows=document.getElementById("tbl").rows.length; alert(rows); }</script></head><body><table id="tbl"> <tr><td>Row 1</td></tr> <tr><td>Row 2</td></tr> <tr><td>Row 3</td></tr> <tr><td>Row 4</td></tr></table><input type="button" value="count" onClick="javascript:countTableRows()"></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted January 12, 2012 Share Posted January 12, 2012 The first thing you need to do is make that a valid page. A valid page only has 1 html element, 1 head, and 1 body. It looks like you have the same code duplicated 3 times, I don't know if that's just an error when you pasted the code or not. Put the text box on the page and give it an ID, and use document.getElementById to get the text box and use the value property to update the text in the box with whatever you want. http://www.w3schools.com/jsref/prop_text_value.asp Link to comment Share on other sites More sharing options...
ashleyfoozi Posted January 13, 2012 Author Share Posted January 13, 2012 Thank you very much.I don't know how I managed to copy and paste the same code 3 times. I thought it was only possible to stutter when talking. Regards Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.