Skip Navigation

[Resolved] Blank field in taxonomy dropdown

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by himanshuS 3 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1889885

The current cred form selects a taxonomy term in the dropdown list when the form loads. This behavior manipulates user actions and make them submit without looking at other options. I want the initial field to be blank and required.
I have been able to make the field required with custom code . But, I am surprised to not see an option to have a blank field in the taxonomy dropdown.

Is there a way this could be done natively?

Reference: https://toolset.com/forums/topic/taxonomy-elect-dropdown-default-value/

#1889887
Image.png

I tired to do this:
$("#theSelectId").prepend("<option value='' selected='selected'></option>");

in the form JS editor as:
$("#cred_form_5371_1-select-3-1609268167").prepend("<option value='' selected='selected'></option>");

But this does not work. What am I missing?

Thanks for your help.

#1890405

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please try to add the following jQuery code to add default option to your taxonomy select box. Please try to add the following code to your Form's JS box:

jQuery(document).ready(function($){
 
jQuery("select[name='YOUR-SELECT-NAME']").prepend('<option value="">- Please Select -</option>');
jQuery("select[name='YOUR-SELECT-NAME']")[0].selectedIndex = 0;
});

Where:
- Replace 'YOUR-SELECT-NAME' with your original select name

I hope the solution shared above will help you to resolve your issue.

#1890739

My issue is resolved now. Thank you!