Dynamically Add/Remove Any number of Textboxes

<?php $max_no_boxes=10; ?>
 <script type="text/javascript">
 function addnames() {
 document.getElementById("totalnames").value	=
 Number(document.getElementById("totalnames").value) +	Number(1);
 Number(<?php echo $max_no_boxes ?>)){
 document.getElementById("totalnames").value=<?php echo $max_no_boxes ?>;
 function removenames() {
 document.getElementById("totalnames").value	=
 Number(document.getElementById("totalnames").value) -	Number(1);
 Number(<?php echo $max_no_boxes ?>))

 <td valign="top">Name</td>
 <td valign="top">
 <div class="project_right">
 <?php for($i=2;$i<=$max_no_boxes;$i++) { 	$nameValue	=	"name".$i; ?>
  <div style="display:<?php echo $totalnames>= $i ?"block":"none"; ?>"
  id="name<?= $i ?>">
 : <input type="text" name="name<?= $i ?>"  class="projectText"
 value="<?php echo $$nameValue ?>">
 <a href="javascript:return false;" onClick="javascript:removenames();">Remove</a>
 <?php } ?>
 <div style="width:175px;; clear: left; float:left">:
 <input type="text" name="name1" class="projectText"
 value="<?php echo $name1 ; ?>">
 <div style="width:20px; clear: none; float:left">
 <a id="nameButton" href="javascript:return false;"
 <input type="hidden" id="totalnames"  name="totalnames"
 value="<?php echo $totalnames==""?1:$totalnames; ?>" />

One thought on “Dynamically Add/Remove Any number of Textboxes”

  1. I would like to thnkx for that efforts you’ve set in composing this website. I’m hoping the same high-grade website submit from you in the upcoming as well. In fact your creative creating abilities has inspired me to acquire my own web site now. Truly the running a blog is spreading its wings quickly. Your write up can be a great example of it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>