[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 10-22-2005, 11:48 AM   #1 (permalink)
NamePros Member
 
SquireQuack's Avatar
 
Join Date: Aug 2005
Posts: 125
525.30 NP$ (Donate)

SquireQuack is on a distinguished road


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!
SquireQuack is offline  
Old 10-22-2005, 12:10 PM   #2 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future

Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
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!
mholt is offline  
Old 10-22-2005, 12:14 PM   #3 (permalink)
NamePros Member
 
SquireQuack's Avatar
 
Join Date: Aug 2005
Posts: 125
525.30 NP$ (Donate)

SquireQuack is on a distinguished road


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!
SquireQuack is offline  
Old 10-22-2005, 12:22 PM   #4 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future

Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
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!
mholt is offline  
Old 10-22-2005, 11:37 PM   #5 (permalink)
NamePros Member
 
Join Date: Oct 2005
Location: USA
Posts: 196
7.05 NP$ (Donate)

ralxz is an unknown quantity at this point


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.
__________________
Freelance Graphic Designer for Hire
Portfolio

Contact info here.
ralxz is offline  
Old 10-23-2005, 06:00 AM   #6 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future

Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
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!
mholt is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prescreening.com espllc Domain Appraisals 13 04-11-2005 07:13 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:37 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85