Skip to content

Patch: gppa-select-first-random-choice-on-radio.js #666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

haneef95
Copy link

@haneef95 haneef95 commented May 23, 2023

Context

This has also been tested to work with GP Populate Anything.

Copy link
Contributor

@claygriffiths claygriffiths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @haneef95, thanks for the PR!

Does it work if you trigger a change event instead of a click?

Comment on lines +9 to +12
// click vs checked: Click triggers other GPPA Fields to be populated appropriately as well, whereas checked does not trigger further reloads.
// Update "3" to the the ID of your Radio Button field, and keep it as "0" for for the first choice.
// Rename "SelectDefaultRoomType" to something unique.
const SelectDefaultRoomType = document.getElementById('choice_' + GFFORMID + '_3_0'); SelectDefaultRoomType.click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// click vs checked: Click triggers other GPPA Fields to be populated appropriately as well, whereas checked does not trigger further reloads.
// Update "3" to the the ID of your Radio Button field, and keep it as "0" for for the first choice.
// Rename "SelectDefaultRoomType" to something unique.
const SelectDefaultRoomType = document.getElementById('choice_' + GFFORMID + '_3_0'); SelectDefaultRoomType.click();
// Update "4" to the the ID of your Radio Button field.
$( 'input[id^=choice_' + GFFORMID + '_4_' )
.prop( 'checked', true )
.trigger( 'change' );

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had to do this though, mention the option as well (not only the field):
$( 'input[id^=choice_' + GFFORMID + '_3_0' ).prop( 'checked', true ).trigger( 'change' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants