| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Aug 2005
Posts: 125
![]() | 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 Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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. |
| |
| | THREAD STARTER #3 (permalink) |
| NamePros Member Join Date: Aug 2005
Posts: 125
![]() | 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 Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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. |
| |
| | #5 (permalink) |
| NamePros Member Join Date: Oct 2005 Location: USA
Posts: 196
![]() | 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. |
| |
![]() |
| 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 08:13 PM |