OriginalBoy Posted June 15, 2008 Share Posted June 15, 2008 Hey, I am making a quotation form for my web design business. I want it so if they change the value of the website pages I want it to add more fields so there is a box for each page. How is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/110332-adding-fields/ Share on other sites More sharing options...
corbin Posted June 15, 2008 Share Posted June 15, 2008 "I want it so if they change the value of the website pages I want it to add more fields so there is a box for each page." Huh? Can you elaborate? As with any user input, you'll need to store it somewhere, and then dynamically display it. For example, you may have a page where users can submit information, and then this information will be stored in a database. Your other pages then retrieve that information from the database. Quote Link to comment https://forums.phpfreaks.com/topic/110332-adding-fields/#findComment-566084 Share on other sites More sharing options...
OriginalBoy Posted June 15, 2008 Author Share Posted June 15, 2008 Example: They select 5 pages from a drop down list... Then 5 boxes come up so I can then fill out info for page 1, page 2, page 3 etc. Quote Link to comment https://forums.phpfreaks.com/topic/110332-adding-fields/#findComment-566088 Share on other sites More sharing options...
corbin Posted June 15, 2008 Share Posted June 15, 2008 Oh I get it now, a quote as in price estimate. I was thinking quote as in: Corbin said, "Hello!" OK hrmmmm... You could do it in javascript, and the page wouldn't have to reload, but here's how you could do it in PHP: <?php $showform = true; if($_POST) { $page_cnt = (isset($_POST['page_cnt'])) ? (int) $page_cnt : null; //if the post val is set, use it, else use null... If it is set, cast it to an integer... if($page_cnt > 0 && $page_cnt < 100) { //0 < page count < 100...I doubt anyone would have a legit reason for saying more than 100 pgs.... really even 20... but... lol $showform = false; echo '<form action="" method="POST">' for($i = 0; $i < $page_cnt; ++$i) { echo '<textarea name="page[]"></textarea>'; } echo '<input type="submit" value="Go!" />'; echo '</form>'; } else { echo 'Please select a valid Page Count.'; } } if($showform) { //user hasn't chosen a number, or it was an invalid number } ?> You would need to mod that for it to actually be of any use, but it should be a start to atleast show you how to do it. Quote Link to comment https://forums.phpfreaks.com/topic/110332-adding-fields/#findComment-566091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.