Jump to content

Recommended Posts

Hey All!

 

Well, here I am at PHP Freaks mercy again lol. I love this website and everyone here is always so helpful so let's get to my most recent issue.

 

I am developing a pretty simple event registration form, which would be pretty easy in most respects. It will have the following pretty standard fields.

 

[*]Number of people attending: (drop down with 1-10)

[*]Name

[*]Address

[*]City

[*]State

[*]Zip

[*]Email

[*]Phone

[*]Alternate Phone

 

There will be a few other fields but they aren't relevant. Basically the first field "Number of people attending (drop down 1-10)" will have to create a section with the following fields above for each person's information. If there are 3 people attending then it will need to have 3 sections of all those fields for each person.

 

Making the page dynamically generate those sections on-the-fly when the user selects "3" for example is the first issue I am having. The other issue I am having is how would I handle the information dynamically within the PHP. If there was just one person it would be easy because I could just reference those fields.

 

One solution I have for the second problem that I have some experience with is naming the fields name[] for example. But I still don't have a complete grasp on how to make that fix my problem. I've tried googling for hours but have had no luck, which may be because I'm not sure how to phrase the problem maybe.

 

Any help!

 

Link to comment
https://forums.phpfreaks.com/topic/237688-event-registration-form-issue/
Share on other sites

First issue. Any time you want something "on the fly" so you say, you need ajax. I'm not the guy to help you with that.

 

Second issue. You got it right. That creates an array called name, which you can use just like any other array. In your processing, do this:

if ($_POST['name']) { // says if something was posted
     foreach ($_POST['name'] as $key => $value) {// says for each thing posted in the names array do something
          //your stuff here ($key will be the input name, $value the users submission
     }
}

 

Hope that helps

 

*Sorry for the double post, meant to edit the first post and accidentally quoted it instead*

Yea that was a great help with the 2nd issue. Thanks so much! :)

 

Do you think you may be able to point me in the right direction to find a solution for the 1st issue? I posted in the Jquery forums and a few others so we will see what happens with that. If you have any other suggestions they will be more than welcome lol!

For the first problem, you don't need AJAX. simple Javascript will suffice, though, if you are comfortable with Jquery, or would like to learn it, Jquery is the way I would do it. It is cross-browser compatible (as all the different ways browsers interpret javascript, especially DOM functionality is behind the scenes in Jquery), and makes development of DOM altering features alot easier and quicker.

 

if you are interested in Jquery, try this tutorial: http://www.w3schools.com/jquery/default.asp

 

If you simply want a javascript solution, try a google search for altering the HTML DOM with javascript. Also, if you are unfamiliar with javascript in general, I would google for few javascript tutorials, and read about how it works, because using Jquery without a solid understanding of javascript is a recipe for disaster

 

But this isn't quite the correct forum to go over this, so you may have more luck asking about this in the javascript help forum

For the first problem, you don't need AJAX. simple Javascript will suffice, though, if you are comfortable with Jquery, or would like to learn it, Jquery is the way I would do it. It is cross-browser compatible (as all the different ways browsers interpret javascript, especially DOM functionality is behind the scenes in Jquery), and makes development of DOM altering features alot easier and quicker.

 

if you are interested in Jquery, try this tutorial: http://www.w3schools.com/jquery/default.asp

 

If you simply want a javascript solution, try a google search for altering the HTML DOM with javascript. Also, if you are unfamiliar with javascript in general, I would google for few javascript tutorials, and read about how it works, because using Jquery without a solid understanding of javascript is a recipe for disaster

 

But this isn't quite the correct forum to go over this, so you may have more luck asking about this in the javascript help forum

http://www.w3fools.com

hehe fugux is the new pr manager for w3schools.

 

you could also do it without jscript, and have it all handled by the PHP, but you would have to have a pre form, for want of a better phrase, which asked how many people, then when posted, it would spit back a form with the correct number of entries for the number of people selected, based on the number in the pre form

Well in order for PHP to do it, you would need a form submit, which ultimately leads to a page refresh/reload. I was under the impression that OP wanted to do this without a page refresh, in which case you would need javascript.

 

Also, yes, w3 schools has some outdated information, but its a good resource for beginner level tutorials and reading. If he wants to do his own research he is free to, but that is the link I gave. He can do with it what he will

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.