note 76795 added to tutorial.forms

From: Date: Tue, 31 Jul 2007 05:46:18 +0000
Subject: note 76795 added to tutorial.forms
Groups: php.notes 
Request: Send a blank email to php-notes+get-129066@lists.php.net to get a copy of this message
Here is a PHP script to add more form fields in a page by clicking on a button on the same page.You can add unlimited number of fields dynamically(in run time) in a page by using this script. (For the alligning of form fields,forms are given in layers) <html> <style type="text/css"> #Layer1 { position:absolute; left:413px; top:123px; width:203px; height:35px; z-index:1; } #Layer2 { position:absolute; left:21px; top:122px; width:389px; height:50px; z-index:2; } </style> <body> <? $n=0; $n1=$_POST['hf']; if($n1>=$n){ $t=$n1;} else{ $t=$n;} /*For example this script allows user to add more and more file upload fields in a page by clicking on a button*/ ?> <!--creating a form--><!--save this page as "upload.php" --> <div id="Layer1"> <form name="form1" method="post" action="upload.php"> <!--creating a hidden field and sets it's value as $t--> <input name="hf" type="hidden" id="hf" value="<? echo ++$t; ?>"> <!--creating a button.When we click this, a new field will be generated--> <input type="submit" name="Submit" value="one more"> </form> <!--another form to submit the uploaded file to be processed--> <!--the upload script should be written in the file "uploader.php"--> </div> <div id="Layer2"> <form action="uploader.php" method="post" enctype="multipart/form-data"> <p> <? $i=0; while($i<$t){ echo "Filename:" ?> <label for="file"> <input type="file" name="file" id="file" > <input type="submit" name="submit" value="Submit" > <?++$i;}?> </form> </div> </body> </html> Like this, you can add any type of form field into the same page by the click of a button. ---- Server IP: 203.199.69.133 Probable Submitter: 61.1.235.222 ---- Manual Page -- http://www.php.net/manual/en/tutorial.forms.php Edit -- https://master.php.net/note/edit/76795 Del: integrated -- https://master.php.net/note/delete/76795/integrated Del: useless -- https://master.php.net/note/delete/76795/useless Del: bad code -- https://master.php.net/note/delete/76795/bad+code Del: spam -- https://master.php.net/note/delete/76795/spam Del: non-english -- https://master.php.net/note/delete/76795/non-english Del: in docs -- https://master.php.net/note/delete/76795/in+docs Del: other reasons-- https://master.php.net/note/delete/76795 Reject -- https://master.php.net/note/reject/76795 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129066) next »