Skip Navigation

[Resolved] Customise the default value for a "select" element in a form

This support ticket is created 2 years, 6 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Shane 2 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#2189735

Hi,

I've created a form with a selector. if no choice is made in the list, something like "--- not defined ---" is displaying.

How can I change it with "Please select" or something else ?

Thanks for your help.

#2190027

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Fabrice,

Thank you for getting in touch.

You should be able to do it by using this Javascript below to replace the text in the field.

jQuery(document).ready(function(){
  jQuery('.wpt-form-option:nth-child(1)').text('please select');
  });

Add it to the JS editor section of your Form.

Please let me know if this helps.

#2190073

Hi Shane,
Thanks a lot ! It helps. But...😂

Is there a possibility to apply it to some fields and not to some others ?
I explain... I have a list of places, of investment types where the code you gave me is just fine ! But I also have a field with a list of numbers starting from 1 to 5 where the default value should be "1". Here with this code, it's replacing the "1" line by "please select"

#2190147

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Fabrice,

Try doing it like this.

jQuery(document).ready(function(){
  jQuery('.wpt-form-option').first().text('please select');
  });

Thanks,
Shane

#2192035

unfortunately, this doesn't work.

Is there a way to keep the 1 script you gave me but having 1 script per field with a "field selector" in order to choose which field is under the control of this script and another not ?

#2193125

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Fabrice,

This is what i'm working on.

Would you mind providing me with a link to the page where the field is on?

The problem is that all the select fields share the same class so we need to scope it correctly.

Thanks,
Shane

#2193161

Hi Shane,

I f you go to the envelope displayed on the left tab on the main page of the site (hidden link), a popup form is displaying.
This is where it is displayed.

#2193215

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Fabrice,

Can you try this below.

jQuery(document).ready(function(){
  jQuery('#cred_form_12963_1_1_ir-country').text('please select');
  });

This should only target the country dropdown.

You should be able to see the select ID for the other items by inspecting the page element.

Please let me know if this helps.
Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.