Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old November 26th, 2008, 08:00 AM   #1
New Member
 

Join Date: Nov 2008
Location: Singapore
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 scorptique is on a distinguished road
How to generate multiple fields in a form

Hello all!

I want to make a form with a set of text fields and an "add another set" button whereby when I click it, another set of the same fields is generated below it. And the user can continously add sets of fields.

I dont know how to do it I know Javascript supports such feature but does anyone know how to create one using php? Help please.
scorptique is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 10th, 2008, 10:50 AM   #2
New Member
 

Join Date: Dec 2008
Location: China
Age: 30
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 seanpro is on a distinguished road
Re: How to generate multiple fields in a form

I think you better use javascript,or javascript with PHP (AJAX).
If you use javascript,there are two ways:
1: output all your fields and just display one of them,and use 'style="display:none"' CSS to hidden other fields,when user click on "add another set" just use javascript to make it display example:document.getElementById('doc'+div).style.d isplay = 'block';
2:use javascript to add a new field like this:
document.getElementById('attach_' + total).innerHTML = "<input type='file' size='60' name='theFile[]' />"
Hope it will help you.
seanpro is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 10th, 2008, 12:24 PM   #3
Aso
Most Reputable Member
 

Join Date: Oct 2007
Location: UK
Posts: 1,633
Blog Entries: 2
Thanks: 22
Thanked 84 Times in 79 Posts
Rep Altering Power: 0 Aso is on a distinguished road
Re: How to generate multiple fields in a form

As seanpro said, use JS or AJAX (I wouldn't go entirely PHP, since it'll probably get a little messy - plus the user would have to refresh the page every time they want to add an input).

Quirksmode has an ace tutorial and script on dynamically adding form inputs
Aso is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 5th, 2009, 09:30 AM   #4
New Member
 

Join Date: Dec 2008
Location: India
Age: 27
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 openwave is on a distinguished road
Re: How to generate multiple fields in a form

we can use looping concepts, then we can generate text fields more and more.
openwave is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


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
Email form with required fields RobinMarek HTML, XHTML and CSS 4 November 14th, 2008 05:15 PM
Hiding / Showing form fields based on previous form input John Alexander Hopper PHP 1 March 10th, 2008 08:30 AM
Multiple DDLs populating different fields in a form foundsheep .NET 0 February 14th, 2008 11:58 AM
HTML form fields jasonjkd HTML, XHTML and CSS 2 October 15th, 2007 05:58 PM
Form Fields robukni PHP 7 October 10th, 2007 04:26 PM


Search Engine Optimization by vBSEO 3.2.0 RC8