Set Radio Button Checked

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
WABez
User
Posts: 199

Set Radio Button Checked

Post by WABez »

This may be a really dumb question, however I'm struggling to set a radio button client side using jquery.
I have tried:
$("#x_myfield_716023]").prop("checked", true);
... and this works well when testing in the console, but how on earth do you set the radio button when the "appended number" keep on changing every time the page load?

What confuses me is the "appended number" that changes, so I cannot use the name nor the id of the element:
<input type="radio" class="form-check-input ew-custom-option" data-table="mytable" data-field="x_myfield" **name="x_myfield_383588" id="x_myfield_716023"** value="1" data-index="0" style="">

As you can see that both name and id attributes have an appended number (that changes every time the page load). How can I select it to use the jquery code above to set the radio button?

Thank you in advance.


arbei
User
Posts: 9292

Post by arbei »

If the field is a lookup field, you simply use: (Assume v2023)

$("#x_myfield").val("1");


Post Reply