PDA

View Full Version : adding table rows



TonyCable
May 1st, 2009, 07:52 PM
right not sure if this is going to make sense but here we go

i'm creating a ASP page, which is going to have a form in it that needs filling out. part of the form will be a table with a header row, then the next rows will have text boxes that need filling out.

is there a way of putting in a dropdown box that contatins numbers that will dynamically show the rows. for example if i select 5, then five rows of text boxes will appear. if i select 14 then 14 appear.

hope this makes sense

Thanks

ajhauser
May 2nd, 2009, 02:13 AM
I can't answer this question, but someone who can is going to ask if you can link to the sample page or show the code you have already.

I am personally curious what this will be used for, and are you allowing the user the ability to change the number of fields to fill out - or is it a number defined by a seperate action and the form is generated "behind the scenes"?

Edit: If you want this done by a drop down menu, it sounds like you are giving the user the ability to change this on the fly - correct?

TinyScript
May 2nd, 2009, 03:52 AM
You would have to make a routine to create and destroy the elements if you want them to show up between toggles of the select box.

I made this example because I thought you were talking about a text input to create the number of inputs, but what you want is a little more work. This should be a good start.
removeChild
or maybe replaceChild


<html>
<head>
<style type="text/css">
</style>

<script type="text/javascript">
function makeThem(Num){

for (i=0;i<Num;i++){
var Box = document.createElement('input');
var NewBreak = document.createElement('br');
Box.type = 'text';
document.body.appendChild(NewBreak);
document.body.appendChild(Box);

}

}
</script>
</head>
<body>
<input type="text" value="how many" onchange="makeThem(this.value)">
</body></html>

TonyCable
May 5th, 2009, 01:45 PM
this is the code that i have at the moment.

<body>

<p>&nbsp;</p>
<form action="NewEquipSubmit.asp" method="POST" name="NewEquip" id="NewEquip">

<select name="RowNumbers">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>

<p>&nbsp;</p>

<table width="59%" id="table1">
<tr>
<td width="70">&nbsp;</td>
<td width="151">
<p align="center">PC Number</td>
<td width="150">
<p align="center">MO Number</td>
<td width="150">
<p align="center">PR Number</td>
<td width="151">
<p align="center">AX Number</td>
</tr>
<tr>
<td>Asset Tag</td>
<td width="151">
<p>
<input type="text" name="PCNumberNew" size="21">
</p></td>
<td width="150">
<p>
<input type="text" name="MONumberNew" size="21">
</p></td>
<td width="150">
<p>
<input type="text" name="PRNumberNew" size="21">
</p></td>
<td width="151">
<p>
<input type="text" name="AXNumberNew" size="21">
</p></td>
</tr>
</table>

<p>
<input type="submit" value="Submit" name="Submit">
<input type="reset" value="Reset" name="Reset">
</p>
</form>
</body>

i will try the code that you have put above and give that a go.

Thanks for your help so far.