Experts,
I am rather new to javascript. I want to create an html page which can add rows dynamically based on a user input. I wrote a piece of code below. But I don't know how to correctly implement 'addRows()' to do the job.
Thanks for your help.
I am rather new to javascript. I want to create an html page which can add rows dynamically based on a user input. I wrote a piece of code below. But I don't know how to correctly implement 'addRows()' to do the job.
Thanks for your help.
Code:
<html><head><title>Dynamica Form</title>
<script language="JavaScript">
function addRows() {
var userinput = document.getElementById('myid').value;
// alert('userinput = ' + userinput);
}
</script>
<style>
.base { border: solid black 1px; width: 20%; }
</style>
</head>
<body>
<form name="myform" action="#" method="post">
How many rows you want?
<input name='myname' id='myid' type='text' value='1' size=2 onkeyup="addRows();">
<p>
<div class='base'>row1</div>
[COLOR=red]<!--since the default value is 1, we have ONE row originally. -->
<!-- How to add rows here dynamically? -->[/color]
<p>
<div><input type=submit> <input type=reset></div>
</form>
</body>
</html>