How to display default value for Advanced search fields

  • Najeeb
    Najeeb
    Newbie 13 points
    April 30, 2015 at 11:20 am

    This question is regarding Auctionpress theme advanced search.
    Currently the search fields show blank when page loads, untill clicked on a dropdown or select list to select the value.
    Would it be possible to display a caption or a default value e.g. “Select a value …” etc as first value of the select list?

    Also how to display the fields horizontally side by side to each other ?

    Thanks for help

  • Alex Morgan
    Alex Morgan
    Super Guru 1,111 points
    April 30, 2015 at 4:00 pm

    Hi Najeeb,

    1. You can try to add [Select a value …] at the top of your select values on the search field.

    2. you can use css to edit the layout.

  • Najeeb
    Najeeb
    Newbie 13 points
    April 30, 2015 at 5:00 pm

    Thanks for the reply Alex.

    I have a field for ‘Cities’ for example in a select drop down. As this list is being built dynamically, I have no option to add a value manually.

    I want this field to display the first entry in the select box when page loads, so the customers don’t have to select the fields, they just press submit to see the results.

    Thanks

    Attachments:
    You must be logged in to view attached files.
  • Alex Morgan
    Alex Morgan
    Super Guru 1,111 points
    April 30, 2015 at 5:03 pm

    Hi Najeeb,

    Oh for the country,state,city fields its not possible sorry.You may try to edit the file: framework/class/class_search.php to do this.

    This reply was awarded the best answer by the topic poster.
  • Najeeb
    Najeeb
    Newbie 13 points
    April 30, 2015 at 8:32 pm

    Thank you Alex this really helped me to set the default value in a select drop down list.

    For other users reference who are looking for the same solution, this is what I changed in ramework/class/class_search.php

    1) To pre select first value in City field change code at line number 1526:

    printf( ‘<select name=”%s” class=”form-control input-sm” id=”core_’.$field->key.’_dropdown’.$extraID.'”><option value=””>  </option> ‘, $field_name );

    to

    printf( ‘<select name=”%s” class=”form-control input-sm” id=”core_’.$field->key.’_dropdown’.$extraID.'”> ‘, $field_name );

    See screenshot for reference.

    Hope this helps

    Thanks

    Attachments:
    You must be logged in to view attached files.

  • Josh
    Super Guru 13,875 points
    May 1, 2015 at 6:33 am

    Thanks for sharing 🙂

  • Alex Morgan
    Alex Morgan
    Super Guru 1,111 points
    May 4, 2015 at 8:48 am

    Hi Najeeb,

    That’s great. Thank you for sharing what you have changed 😉

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

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes