Default Category with SELECT option

This topic contains 2 replies, has 3 voices, and was last updated by  Kiran 6 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #448525

    macroclick
    Buyer
    Post count: 25

    I have set the Category Display Type to SELECT in the Settings so that there is only a single list and only a single Category can be applied to a listing. I also want to default this to a certain category ID (45) when adding a listing. In addition, I set to Admin only so users cannot modify.

    When I changed to Select display type the code below no longer works, since it is for multi-select:

    jQuery(document).ready(function(){

    if(location.pathname == “/add-listing/”)
    {
    jQuery(‘#gd_placecategory.chosen_select’).val(’45’).change();
    }

    });

    How can I set the category automatically using the single select?

    #448577

    Kor
    Moderator
    Post count: 16516

    Hi macroclick,

    Thanks for your post. Will forward this to a developer for a second opinion.

    Thanks!

    #448598

    Kiran
    Moderator
    Post count: 7069

    Hello,

    Use following JavaScript snippet.

    
    
    jQuery(function($){
    	if ( $('.geodir_form_row select#gd_placecategory').length) {
    		$('.geodir_form_row select#gd_placecategory option[value=""]').remove();
            $('.geodir_form_row select#gd_placecategory').val(45).trigger("chosen:updated");
    	}
    });

    Kiran

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount