macromedia.coldfusion.advanced_techniques
[Top] [All Lists]

Re: Add textbox button

Subject: Re: Add textbox button
From: "dchard"
Date: Tue, 2 Dec 2008 21:38:42 +0000 UTC
Newsgroups: macromedia.coldfusion.advanced_techniques

This code counts the number of rows existing then add new row with 3 textbox 
after the last row. Each textbox have their own unique name

 <script language="javascript"> 

 function addRow(){ 
 var newRow = 
document.getElementById("mytable").insertRow(document.getElementById("mytable").
rows.length);
 var num = ((document.getElementById("mytable").rows.length - 1) * 3) - 1;

 //add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes

 var oCell = newRow.insertCell(0);
 oCell.height = '25';
 oCell.vAlign = 'middle';
 oCell.align = 'center';
 oCell.style.background = '#EEEEEE';
 oCell.innerHTML = "<input type='text' name='textfield"+(num)+"' 
class='bodytext' size='20' align='center'>";

 oCell = newRow.insertCell(1);
 oCell.height = '25';
 oCell.vAlign = 'middle';
 oCell.align = 'center';
 oCell.style.background = '#EEEEEE';
 oCell.innerHTML = "<input type='text' name='textfield"+(num + 1)+"' 
class='bodytext' size='35' align='center'>";

 oCell = newRow.insertCell(2);
 oCell.height = '25';
 oCell.vAlign = 'middle';
 oCell.align = 'center';
 oCell.style.background = '#EEEEEE';
 oCell.innerHTML = "<input type='text' name='textfield"+(num + 2)+"' 
class='bodytext' size='3' align='center'>"; 

 } 

 </script>


<Prev in Thread] Current Thread [Next in Thread>