• Resolved JsonB123

    (@jsonb123)


    I’m trying to get input from checkboxes (tags, or any other custom taxonomy) to get taken in and parsed with QMT plugin. I have the checkboxes set up, but of course when I give them all the appropriate name, only the last set checkbox gets sent:

    <input type="checkbox" name="tag" value="tag-one" />

    I also tried doing it as you would with an array

    <input type="checkbox" name="tag[]" value="tag-one /> and so on so that they all get taken in. This also doesn’t work.

    How do I set this up properly so that I can send data to the Search where if more than one checked box were selected the query would be as follows, in the URL:

    https://myblog.com/?tag=tag-one+tag-two

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter JsonB123

    (@jsonb123)

    Bumping the question…just in case anyone has any idea (I mis-labled the tags on this post originally).

    How do I set this up properly so that I can send data to the Search where if more than one checked box were selected the query would be as follows, in the URL:

    https://myblog.com/?tag=tag-one+tag-two

    That’s something you could achieve with a little bit of jQuery (only tested in Firefox):

    jQuery('#myform').submit(function() {
        var $form = $(this),
            values = [];
    
        // remove checkboxes, while keeping their values
        $(':checked').each(function() {
            values.push( $(this).remove().val() );
        });
    
        // create a new text input with the concatenated value
        $form.prepend( $('<input>').attr({
            'type': 'text',
            'name': 'tag',
            'value': values.join('+')
        }) );
    });

    Replace #myform with your own selector. Also, you might want to replace the :checked selector with something more specific.

    Thread Starter JsonB123

    (@jsonb123)

    Good point. I was hoping not to resort to requiring JS for this…but I suppose that this is one of those cases where it is easier to do that than try to hack the PHP functionality of wordpress.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sending an array of values to QMT?’ is closed to new replies.