| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Member | Please help clarify logistics I'm scripting a form in HTML and PHP. I need to have a link that adds extra fields , named inputX when when click. My problem is, how do display all fields using $_POST['inputX']?
__________________ upload² |AIMForum.com - Ready, AIM, Chat!|Google Talk Forum - Where the world talks about Google! Forum Elves - Quality Forum Posting At Affordable Prices! -|Order A Package|PaidPosts.com Help Boost Your Forum|BannerManage.com Sell direct advertisements on your website effortlessly! |
| |
| | #2 (permalink) |
| DNOA Member | The name of the field should be like this: <input name="inputX[]"> PHP will automatically create an array and you can use it when you process it. Be warned that if a user skips a field (e.g. leaves one blank), and goes to fill out the next one, it will IGNORE the empty fields, meaning it won't even make them part of the array.
__________________ codeboards A high-quality community of programmers -- Join today and post! We want new members! |
| |
| | #3 (permalink) |
| NamePros Member | Thanks for the help! Got a another question. What's the best way to add more fields? I'm a little unfamiliar with using the "?act" in /doc.php?act=action or do=action how does that exactly work? How do I define what it does?
__________________ upload² |AIMForum.com - Ready, AIM, Chat!|Google Talk Forum - Where the world talks about Google! Forum Elves - Quality Forum Posting At Affordable Prices! -|Order A Package|PaidPosts.com Help Boost Your Forum|BannerManage.com Sell direct advertisements on your website effortlessly! |
| |
| | #4 (permalink) |
| DNOA Member | In a URL, any text after a ? character is declaring variables. file.php?variable=value&variable2=another_value Use it as sparingly as you can as it presents security problems. You can then retrieve the variables in PHP like this: $variable = $_GET['variable']; Otherwise, the best way to add more fields is to use JavaScript, which would be instant as soon as you click a link or button. Or, you could use PHP and reload the page, but you need to find a way to keep the values. I recommend javascript.
__________________ codeboards A high-quality community of programmers -- Join today and post! We want new members! |
| |
| | #5 (permalink) |
| NamePros Member | As compuXP said, I also reccomend JavaScript to add fields instantly. The only problem I see, though, is if javascript is disabled. Although it doesn't seem likely, a lot of users actually have javascript disabled (either manually, by an antivirus program, etc). Maybe if you could detect if javascript is enabled on the client's computer, and then display the preffered way. |
| |
| | #6 (permalink) |
| DNOA Member | At least display a notice that Javascript is required... if you really want compatibility make it detect if it's enabled - if not then do it slowly by a PHP reload.
__________________ codeboards A high-quality community of programmers -- Join today and post! We want new members! |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Prescreening.com | espllc | Domain Appraisals | 13 | 04-11-2005 07:13 PM |