Re: Dynamic input fields in Form

From: Date: Sat, 08 Feb 2003 08:13:42 +0000
Subject: Re: Dynamic input fields in Form
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-134861@lists.php.net to get a copy of this message
Hi, Thanks guys for helping me out! Regards, Frank ---- Original Message ----- From: "1LT John W. Holmes" <holmes072000@charter.net> To: "Frank Keessen" <fkeessen@planet.nl>; "Jon Haworth" <jhaworth@witanjardine.co.uk>; <php-general@lists.php.net> Sent: Friday, February 07, 2003 9:23 PM Subject: Re: [PHP] Dynamic input fields in Form > > Thanks for the answer; but there is nobody who can show me an example in > > code??? > > You mean do the work for you? Do you want the PHP or Javascript solution? > Only one can be posted on this list... > No you don't have to do the coding for me!!!! > The PHP one is simple. Assuming $_POST['num'] is the number from your drop > down... > > for($x=0;$x<$_POST['num'];$x++) > { echo '<input type="text">'; } > > That's it. > > ---John Holmes... > > > > > I have a form where the user selects for example; how many cars > > > > you have: 4. Then it most dynamicly create 4 input fields > > > [...] > > > > > > Using only PHP, you'll have to make this a two-step process where page 1 > > > collects the number of cars and posts to page 2, which generates the > form > > > accordingly. > > > > > > If is has to be done on the same page, you'll need to call a Javascript > > > function every time the number of cars changes. That function will have > to > > > add or remove <input>s from the form depending on the number of cars > > > entered, and of course the whole page will break completely for anyone > > > without Javascript. > > > > > > I'd make it a two-step process myself, it's considerably more robust and > > > offers considerably less room for problems (what happens if I claim I > have > > > five cars, fill out their details, and then change it to three cars? > which > > > details do you get rid of?) > > > > > > Cheers > > > Jon > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#134861) next »