All pastes #636608 Raw Edit

Anonymous

public text v1 · immutable
#636608 ·published 2007-07-28 01:52 UTC
rendered paste body
<head>

<SCRIPT TYPE="text/JavaScript">
var counter = 0;

function addRow(id)

{
    counter++;
    
	//get control of the table.

	var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
	
	//create the input objects

	var input1 = document.createElement("input");

	    input1.type="text";
	    input1.size="45"

	    input1.name="name"+counter;
	    input1.id="name"+counter;
	    input1.value="name"+counter;
	    

	var input2 = document.createElement("input");

	    input2.type="text";
	    input2.size="25"

	    input2.name="jobNumber"+counter;
	    input2.id="jobNumber"+counter;
	    input2.value="jobNumber"+counter;
	   

	var input3 = document.createElement("input");

	    input3.type="text";
	    input3.size="45"

	    input3.name="area"+counter;
	    input3.id="area"+counter;
	    input3.value="area"+counter;
	
	//create the row object

    var row = document.createElement("TR");
    
    //create the cells

    var td1 = document.createElement("TD");

    var td2 = document.createElement("TD");

    var td3 = document.createElement("TD");
    
    //attach the row the the table
    tbody.appendChild(row);

    
    //add the cells to the row
    row.appendChild(td1);

    row.appendChild(td2);

    row.appendChild(td3);
    	
    //add the inputs to the cells

    td1.appendChild(input1);

    td2.appendChild(input2);

    td3.appendChild(input3);
    
    var counterInput = document.getElementById('numberEntries');
    counterInput.value=counter;

}


</script>

</head>



<body>

<div style="float:left;"><a href="javascript:addRow('myTable')">Add Row</a></div>



<form enctype="multipart/form-data" name="login" action="" method=post>
<input type="text" value="0" name="numberEntries" id="numberEntries"></input>

	<table width="800" border="1" align="center" bordercolor="#000000" id="myTable">

	    <tbody>

	      <tr>

	        <td width="299" id="myTable"><input name="name0" type="text" id="nama" size="45"></td>

	        <td width="186"><input name="jobNumber0" type="text" id="penasihat" size="25"></td>

	        <td width="293"><input name="jobNumber1" type="text" id="jawatan" size="45"></td>

	      </tr>

	    </tbody>

	</table>
	<p/><center><INPUT type="submit" value="Create User" id="submit_button"></center>
</form>