Home Forums General Issues Conditional Select Values with two selects


Conditional Select Values with two selects

  • Hi, I need to create a select menu where user chooses a CAR BRAND and in the other select menu the MODEL CAR.
    But I need that when user selects one CAR BRAND the MODEL CAR SELECT only chows the models for thar brand.

    Is this possible?

    I have found this but it’s to old and it doesnt work


  • Yes it works – it works with a little bit knowledge using the perfect example from Hube – but it works also with standard ACF functions. You should use a standard select field with UI and AJAX activated. Your PHP action load_field should be set for this field and load the correct data. This is for both fields. Your second field should “hear” on $_POST[‘your_var_brand’] and then you should do a little bit work on your JS file…..

    Have a look at the ACF JavaScript API documentation. The keyword should be:

    acf.addFilter('select2_ajax_data', function( data, args, $input, field, instance )

    I have used this in my actual plugin project in 15 fields and it works great.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.