Skip Navigation

[Resolved] Using jQuery to show/hide conditional custom field and its label

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

Last updated by kelvinL-2 3 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#2150145
Screenshot 2021-08-24 at 6.45.28 AM.png
Screenshot 2021-08-24 at 6.44.37 AM.png

Dear Sir/Madam,

I have a post form with some conditional custom field, most of the fields will be showed/hide according to a dropdown field selection. I make the fields in table format, I want to hide the header also if field is conditionally hide, how can I check the value from the dropdown field using jQuery?

Refer to the screenshot, you should see two options from the dropdown, when I change the option, the custom fields will be showed or hide respectively.

Best regards,

Kelvin.

#2150177

Dear Sir/Madam,

I fixed the jQuery to show/hide the custom fields including header, how can I show/hide the fields by checking the url parameter from the parent post or there is such setting to the child post form? Please advise.

#2150389

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

There is no such native feature available that you can show/hide the content based on the URL param.

But have you try to use the [wpv-conditional] statement with [wpv-search-term] shortcode?

Using [wpv-search-term] shortcode you can grab the URL param value.
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term

For example: if the URL contain the pram/value as: ?color=red

[wpv-conditional if="( '[wpv-search-term param='color']' eq 'red' )"]
 This is red color
[/wpv-conditional]
 
#2150711

Dear Minesh,

Thanks for your reply. What I want is to set the value to the parent field

[cred_field field='@application-contestant.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='true']

I want to pass the value to form and set the value of the parent field instead of selection. How can I assign the url parameter value as the parent field value?

Best regards,

Kelvin.

#2151439

Minesh
Supporter

Languages: English (English )

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

what is the URL param name you are passing?

If you set your URL param as: parent_application_id with the requried parent ID you want to pass then the parent dropdown value will be automatically selected.

#2151949
Screenshot 2021-08-26 at 5.51.43 AM.png
Screenshot 2021-08-26 at 5.50.49 AM.png
Screenshot 2021-08-26 at 5.48.51 AM.png

Dear Minesh,

I try adding the URL param parent_application_id but not work. Refer to screenshot, when I type the url as

/add-new-contentant/?parent_application_id=2565

then it will be redirected to

/add-new-contentant/?parent_application_id=2565&doing_wp_cron=1629928239.1215760707855224609375

I want to add the button with passing the parent application id, what is the url should be? I tried to type the url from browser, I don't see the parent field is auto selected. You can see my parent post with id 2565 is existed.

Here is the parent post field code

	<div class="form-group">
		<label for="%%FORM_ID%%_@application-contestant.parent">[cred_i18n name='@application-contestant.parent-label']Applications Contestants[/cred_i18n]</label>
		[cred_field field='@application-contestant.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='true']
	</div>
#2152283

Minesh
Supporter

Languages: English (English )

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

That is strange. What is your parent post type slug?

What if you try ?parent_applications_id=2565 - does that works?

#2152427

Dear Minesh,

Thanks for your reply. I checked my parent post slug is vwcm-application, after changing to parent_vwcm-application_id, it works now.

#2152499

Minesh
Supporter

Languages: English (English )

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

Glad to know that its working now. you are welcome to close this ticket.

#2152585

My issue is resolved now. Thank you!