Re: Form Elements - user adding dynamically
| From: | Marek Kilimajer | Date: | Tue, 17 Jun 2003 14:58:23 +0000 |
| Subject: | Re: Form Elements - user adding dynamically | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151843@lists.php.net to get a copy of this message | ||
function newNumber(f) {
var newfile=document.createElement("input");
newfile.setAttribute("type","text");
newfile.setAttribute("name","number[]");
f.appendChild(newfile);
f.appendChild(document.createElement("br")); // simply add this line
}
You might want to take a look at some DOM tutorials, at http://www.brainjar.com/ are a few good ones.
Boaz Yahav wrote:
How would you make the input boxes open one above the other instead of one after the other? Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -----Original Message----- From: Marek Kilimajer [mailto:kilimajer@webglobe.sk] Sent: Tuesday, June 17, 2003 4:18 PM To: Nelson Goforth Cc: php-general@lists.php.net Subject: Re: [PHP] Form Elements - user adding dynamically You can use DOM: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"> <html> <head> <title>Any number you like</title> <script language="JavaScript1.2"> function newNumber(f) { var newfile=document.createElement("input"); newfile.setAttribute("type","text"); newfile.setAttribute("name","number[]"); f.appendChild(newfile); } </script> </head> <body> <pre> <?php print_r($_POST); ?> </pre> <form action="subory.php" method="post" enctype="multipart/form-data"> <input type="submit"> <input type="button" value="More" onClick="newNumber(this.form);"> </form> </body> </html> Nelson Goforth wrote:I'm constructing an HTML form (via PHP) in which I want the user to be able to add or delete elements as needed. For instance, in a page detailing user information, the user might have one phone or several. Rather than having a set number of slots for phone numbers I'd have one slot and have a button by which the user could add a slot. The user could also delete a number in a similarmanner.The design goal is something like Apple's iTools web page construction tool. Beside each slot is a "-" and a "+" to delete that slot or toaddanother one just under the existing slot. I've got something worked out that is beginning to work, but I wondered if anyone on the list had faced a similar problem or knows of anexamplescript that handles a problem like that. Thanks, Nelson