7 years ago
Topic

Hi,

I'm trying to pass the selected values of a multiple selectbox through ajax to the live config for a field.

I have selected variable in the live field config and then selected array but I get the following error:

Warning: strlen() expects parameter 1 to be string, array given in /var/www/vhosts/dev.*****.co.uk/libraries/cms/cck/database.php on line 22

Get a VIP membership
7 years ago
1
Level 1

This is the code I'm using to grap the values from the selectbox:

var catIDs = new Array();
jQuery("#cat_filter").each(function() {
catIDs.push(jQuery(this).val());
});

I'm then trying to pass these through an ajax GET command but get the above error.

I have tried to put the values into a comma seperated string but don't know how to interpret that at the other end.   I tried change the variables config to Integers but that doesn't work either, works for 1 selected value but not multiple.

I was also looking at the match options and don't see an "in" match although there is a "not in" match whcih seems like an obmission?

7 years ago
0
Level 2

OK mybe if I put this another way.

I can't pass multiple values to the variable live element.

Neither strings or Array seem to handle my values correctly.  I have searched for documentation but canb't find anything which explains it properly.

Does anyone have any experience of doing this in a search form?

7 years ago
6
Level 1

So I have my search field in my form as a new select box without storage.

I then have my filter field, in this case categories with the live field set as variable and the confgire of Array with a variable paramater set which relates to the param sent through my form.

Now I get a slightly different error:

Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /var/www/vhosts/****.co.uk/dev.****.co.uk/libraries/joomla/database/driver/mysqli.php on line 246

Does anyone have any idea how I can pass these multiple selected variables through to the filter field in a way that works?

Please.

4229 Posts
Kadministrator
7 years ago
5
Level 2

Obviously your endpoint only accepts strings, not arrays. How do you store your value?

7 years ago
4
Level 3

Obvious to you maybe.

I'm using multiple select select box and passing all the values selected through ajax.  The values are passed as an array.

What does the array option in Variable  live option do then?

4229 Posts
Kadministrator
7 years ago
3
Level 4

Ajax is always submited somewhere, so my questions is where? You need tome function on server side to accept and store values your are passing trough ajax.

7 years ago
2
Level 5

I'm using the method in the url below, trying to extend it for a multiselect selectbox+keyword text field filers.:

https://www.seblod.com/community/forums/lists-search-types/ajax-based-filter

4229 Posts
Kadministrator
7 years ago
1
Level 6

That is a crucial piece of information that was missing, hard to just guess what you are doing :)

In your search type set Matching to any of the Word options( Any words,Each word. Each word exact etc.. ) on the select field in the mutiple mode with array as live value.

7 years ago
0
Level 7

That did it Klaas, thank you!

What's obvious to one may not be to the next!  ;-) 

Can I mark this as solved

Get a Book for SEBLOD