Click here to Skip to main content
15,890,043 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: upload photo Pin
EliottA16-Sep-09 6:10
EliottA16-Sep-09 6:10 
AnswerRe: upload photo Pin
Marc Firth17-Sep-09 14:37
Marc Firth17-Sep-09 14:37 
Questionsend email Pin
pallavi shrivastava15-Sep-09 2:59
pallavi shrivastava15-Sep-09 2:59 
AnswerRe: send email Pin
fly90415-Sep-09 7:42
fly90415-Sep-09 7:42 
QuestionGridview Pin
jaraldumary15-Sep-09 0:51
jaraldumary15-Sep-09 0:51 
AnswerRe: Gridview Pin
fly90415-Sep-09 7:34
fly90415-Sep-09 7:34 
AnswerRe: Gridview (caution, long answer) Pin
enhzflep15-Sep-09 14:56
enhzflep15-Sep-09 14:56 
GeneralRe: Gridview (caution, long answer) Pin
fly90423-Sep-09 2:21
fly90423-Sep-09 2:21 
I'm not a fan of just writing HTML with javascript e.g. str += '</tr>';

I would rather use the document.createElement( [tag name] ); function. I'm also a huge fan of jQuery.

Below is how I would go about creating a table in Javascript.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Create Table</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">

    function createTable(rows, columns, newId, parent)
    {
    	    $(parent)
	    .append(

		    $(document.createElement('table'))
		    .attr('id' , newId)

	    );

	    for (var rowNumber = 1; rowNumber <= rows; rowNumber++)
	    {
		    $('#' + newId)
		    .append(

			    $(document.createElement('tr'))
			    .attr('class', (rowNumber % 2 == 0) ? 'even' : 'odd')

		    );

		    for (var columnNumber = 1; columnNumber <= columns; columnNumber++)
		    {
			    $('#' + newId + ' tr:last-child')
			    .append(

				    $(document.createElement('td'))
				    .html('(' + columnNumber + ', ' + rowNumber + ')')

			    );
		    }
	    }
    }

    </script>
</head>
<body onload="createTable(10, 10, 'newTable', '#parent');">

    <div id="parent"></div>

</body>
</html>


Boredom is a wonderful thing.

If at first you don't succeed, you're not Chuck Norris.

QuestionUnable to start yahoo messenger Pin
Vishal Kumar Soni14-Sep-09 10:24
Vishal Kumar Soni14-Sep-09 10:24 
QuestionProblem with PHP IDE Pin
sarang_k11-Sep-09 0:59
sarang_k11-Sep-09 0:59 
AnswerRe: Problem with PHP IDE Pin
Marc Firth11-Sep-09 5:40
Marc Firth11-Sep-09 5:40 
QuestionCURL Post Error [modified] Pin
LazyDragonfist7-Sep-09 4:08
LazyDragonfist7-Sep-09 4:08 
QuestionCreating visual content Pin
Sahir Shah2-Sep-09 23:02
Sahir Shah2-Sep-09 23:02 
AnswerRe: Creating visual content Pin
Marc Firth2-Sep-09 23:32
Marc Firth2-Sep-09 23:32 
AnswerRe: Creating visual content Pin
tagyurit13-Sep-09 10:50
tagyurit13-Sep-09 10:50 
QuestionNumeric value only Pin
udch2-Sep-09 22:03
udch2-Sep-09 22:03 
AnswerRe: Numeric value only Pin
Marc Firth2-Sep-09 23:17
Marc Firth2-Sep-09 23:17 
QuestionKubuntu updates [SOLVED] Pin
rastaVnuce2-Sep-09 4:35
rastaVnuce2-Sep-09 4:35 
Questionappache xampp server Pin
choudhari akash30-Aug-09 23:41
choudhari akash30-Aug-09 23:41 
AnswerRe: appache xampp server Pin
Marc Firth4-Sep-09 3:09
Marc Firth4-Sep-09 3:09 
AnswerRe: appache xampp server Pin
Jayapal Chandran26-Jul-10 8:04
Jayapal Chandran26-Jul-10 8:04 
QuestionErr: This is a marker file generated by the precompilation tool, and should not be deleted! Pin
lakshmichawala26-Aug-09 21:03
lakshmichawala26-Aug-09 21:03 
Questioni need to create a form with different userd id and names and then link it to the my sql database and lot more ------------------ need urgent help Pin
sean_198226-Aug-09 1:05
sean_198226-Aug-09 1:05 
AnswerRe: i need to create a form with different userd id and names and then link it to the my sql database and lot more ------------------ need urgent help Pin
kabirbdboy28-Aug-09 6:09
kabirbdboy28-Aug-09 6:09 
GeneralRe: i need to create a form with different userd id and names and then link it to the my sql database and lot more ------------------ need urgent help Pin
fly90431-Aug-09 12:49
fly90431-Aug-09 12:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.