close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Am I being stupid!!??

Thread began 6/27/2013 5:56 am by Banksie | Last modified 6/27/2013 8:37 am by Jason Byrnes | 637 views | 3 replies |

Banksie

Am I being stupid!!??

I haven't used the Dynamic Dropdowns extension for a while but it fits a project I'm currently involved in perfectly. I've reviewed the help files to build & populate my parent, child and target lists but am struggling to figure out how, on submitting the form, to get each individual selection from the target list (there may be up to 20) to list in the next part of the process (which, effectively creates a "pick list" of the required products for dispatch).

Is it starightforward and something that I've stupidly missed? Or is it case of getting hands-on with the JavaScript to strip out what's required from the array before submitting the form and the resulting multiple selections?

Sign in to reply to this post

Jason ByrnesWebAssist

when working with a multiple select list, you need to edit the name of the list to include square brackets, "[]", at the end.

a multiple select list sends the selections as an array in the post.

so you will also need to have code on the action page to work with the array, for example, the following code would convert the array of selections to a comma separated list:

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

Banksie

Thanks, as always, for the swift reply Jason. However, sorry, no joy!

I think the fault lies in the drop-down page (take a look at in, in beta form, in action at http://www.blendworth.co.uk/test_dynamic_dropdowns3.php).

Whilst I've amended the select field name by appending the square brackets as you recommended (name="targetList[]" id="targetList[]") it doesn't seem to be creating an array. I've modified the request method to GET so that you can see what's being sent.

In addition, I'm only really interested in sending an array of the labels the get selected into targetList[] and not the parentList and childList ids as seems to be happening at the moment.

Any thoughts?

Regards

Gary

Sign in to reply to this post

Jason ByrnesWebAssist

you have to hit the select al button before submitting.

just because the items are added to the list does not mean they are selected in the target list, you need to select them before submitting.

you could also add the set selected in list behavior to the submit button to select all the items in the target list when the form submits automatically.

The labels cannot be passed on submitting the form, on the action page, you would need to create a recordset to return the items that where selected


my previous example converts the posted array to a comma seperated list. this will be a coma seperated list of the selected ID value.

you could create a recordset as:

SELECT * FROM tableName WHERE idColumn IN (".$_POST['targetList'].")

this will return the records for the selections so you can lookup the labels, of course the method will need to be changed back to POST.

Sign in to reply to this post

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...