Skip Navigation

[Resolved] adding javascript to custom field at dashboard

This support ticket is created 3 years, 1 month 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 5 replies, has 2 voices.

Last updated by Minesh 3 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#1969101
Screenshot 2021-02-28 at 12.59.28 AM.png

Dear Sir/Madam,

I have a custom post with custom field, I want to build a button to generate a code to a custom field when creating a custom post from dashboard. is it possible to do?

Best regards,

Kelvin.

#1970323

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I'm afraid that there is no such feature exists. You may have to write custom Javascript/jQuery code that could help you to achieve what you need. If you do not know how to do it, I suggest you to contact Javascript Pro who should help you on this custom requirement.

#1971625

Dear Minesh,

Understood, I may write my own javascript to do, could you tell me how Toolset define the element's name from the dashboard? Is there any standard naming from Toolset?

Best regards,

Kelvin.

#1971961

Minesh
Supporter

Languages: English (English )

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

If you look at the page source or try to Inspect the specific field, you will be able to see the information about the rendered element (field).

More info:
=> hidden link

#1972179

Dear Minesh,

I know how to use the web inspector but I have no idea how Toolset name the element id, like

<div class="js-wpt-field-items">
			<div class="js-wpt-field-item wpt-field-item">
		<div id="post-textfield-7-1614689486-wrapper" class="form-item form-item-textfield wpt-form-item wpt-form-item-textfield">
<input type="text" id="post-textfield-7-1614689486" name="wpcf[score]" value="銀獎" class="wpt-form-textfield form-textfield textfield" data-wpt-type="textfield" data-wpt-id="wpcf-score" data-wpt-name="wpcf[score]"></div>
	</div>
</div>

the id post-textfield-7-1614689486 is being changed everytime, it can't be called by Javascript if I can't sure the name of the id.

Best regards,

Kelvin.

#1972249

Minesh
Supporter

Languages: English (English )

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

Yes - that is true. You should not target the element ID but element name.

For example:

jQuery("input[name='wpcf[score]']").change(function(){
  /// your code
});

jQuery("select[name='wpcf[my-select-field-slug]']").change(function(){
  /// your code
});;

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