Forum Moderators: coopster

Message Too Old, No Replies

PHP and Forms

         

leroybrown71

1:01 am on Mar 30, 2006 (gmt 0)

10+ Year Member



Hello all.. did a long search and couldn't quite find what I was looking for, so hopefully someone has some info for me. Here's what I'm trying to do.

On the main page, a small form, where the user selects the main type of widget they're looking for. We'll call this variable mainwidget. After submitting the variable is passed to form2 ( this is working fine. )

Here's my dilemma. For each mainwidget, there are different types of subwidgets, say 4,5,6 of each. I want to be able to use the $mainwidget variable to determine which subwidgets show up in the subwidget drop-down box in the form on page2. I was thinking about trying to set up a PHP if statement inside the form, for the dropdown box. All other form items are standard for each mainwidget, just the subwidget item needs to be variable. Any ideas on syntax / feasability?

Thanks!

LB

garyr_h

1:30 am on Mar 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand correctly, you have two choices:

1) Use AJAX and just one form instead of two. This will increase userability.

or

2) Use simple IF and ELSE in php.

I would go with 1.

leroybrown71

3:10 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



I like the AJAX idea for future projects, however with this one, there will also be a picture of the basic widget that they selected on page2. I forgot to include that.
For the if statement, do I need to create the whole form separately for each subwidget, or can i put php code inside of the form, and only have part of it generated dynamically? My apologies, I'm no PHP expert by any means.

garyr_h

1:35 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually AJAX could still work with the image. Just put a DIV to the side then use innerHTML (or something else) to write the html into the div.

However, you may use IF/ELSE within a form to answer your question.

coopster

3:42 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, leroybrown71.

It sounds like you are passing the $mainwidget variable to your second page just fine so now you can just use that to build the select options in your next list. Is the data coming from a database? A system file? Just some array options you have setup?

leroybrown71

9:05 pm on Apr 8, 2006 (gmt 0)

10+ Year Member



the options are actually just hardcoded in the php file, as there aren't very many. i did figure it out, my problem was a silly syntax error. I've been programming too long - I should've known better than that ;)