close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Incorporating select box with multiple selections

Thread begun 5/13/2011 7:23 am by admin140217 | Last modified 5/17/2011 6:40 am by Jason Byrnes | 4189 views | 11 replies |

admin140217

Incorporating select box with multiple selections

I'm nearly done with a registration type form I am working on.

I need to create a select list box where multiple selections can be made and sent to the database, the box may have 4-5 different options. Is there a way to incorporate this into the checkout form using ecart 5 or does this have to be hand coded in?


If hand coded, I may need a tutorial to follow if you know of one.

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

make sure to name the select list ending in "[]", for example:
mySelect[]

this will create an array of the selected items.

then on the confirm page, create a hidden form element of the same name in the collection of hidden form elements using the implode function to convert the array to a comma separated list:

<input type="hidden" name="mySelect" value="<?php echo isset($_POST['mySelect'])?implode(", ",$_POST['mySelect']):""; ?>" />

now edit the store order summary behavior, bind the column that will store the selections to the hidden form element.

Sign in to reply to this post

admin140217

Not quite there

Thanks again Jason,

I still have a problem, when it writes to the database in the column assigned (InterestedIn) it is writing the word Array to the database, here is a portion of the code:

Checkout page where the form is located:

<select name="InterestedIn[]" id="InterestedIn" multiple="multiple" size="4">
<option value="DNO">Dad's Night Out</option>
<option value="Meet and Greet">Meet and Greet</option>
<option value="Friday Activity TBD">Friday Activity TBD</option>
<option value="All Activities">All Activities</option>
</select>

In the confirm.php page:

<input type="hidden" name="InterestedIn" value="<?php echo isset($_POST['InterestedIn'])?implode(", ",$_POST['InterestedIn']):""; ?>" />

I'm guessing I don't have something defined properly. In the post statement, is this where I would define the option like so:

php echo isset($_POST['DNO'])?implode

I am not receiving an error in the process.

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy of the checkout and confirm page please.

Sign in to reply to this post

admin140217

Here you go!

Attached Files
checkout.zip
confirm.zip
Sign in to reply to this post

Jason ByrnesWebAssist

Ok, I see, the confirm page has the data set to store on post from the checkout page.

Double click the store order summary behavior, select the column that is storing the list values and edit the code for that column from:

php:
<?php echo isset($_POST['InterestedIn'])?$_POST['InterestedIn']:""?>




to:

php:
<?php echo isset($_POST['InterestedIn'])?implode(", ",$_POST['InterestedIn']):""?>
Sign in to reply to this post

admin140217

Hmmm, it is still just writing the word "Array" and not passing the values of the selection to the database.

Sign in to reply to this post

Jason ByrnesWebAssist

send your latest copy of the confirm page.

Sign in to reply to this post

admin140217

Jason,

Here is the latest file.

Attached Files
confirm.zip
Sign in to reply to this post

Jason ByrnesWebAssist

add the following code at line 1 of the confirm page:

php:
<?php

if($_SERVER["REQUEST_METHOD"] == "POST")     {
    foreach(
$_POST as $key => $val) {
        if(
is_array($_POST[$key])) $_POST[$key] = implode(", "$_POST[$key]);
    }
}
?>
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...