I'm looking to use existing custom HTML buttons to check either a Yes or No checkbox on a form. The purpose is to direct the form through an exclusive gateway depending on which button is clicked. There are only two possible outcomes, Yes or No.
The custom HTML code is as follows:
<input id="btnPayCard" value="Pay by Credit Card" type="button"> <input id="btnPayCash" value="Pay by Cash, Check or PO" type="button">
The checkbox I would like to fill is a field called 'Paid'. There is either a 'Yes' or 'No' option to be checked. If 'btnPayCard' is clicked I would like the 'Yes' checkbox checked, and if 'btnPayCash' is clicked 'No' should be checked. This could function in the same matter with a radio button if needed.
My current JavaScript, which is not working, is as follows. I am a novice user of JavaScript so I'm sure I have some glaring mistakes in the code. I added a CSS class to my checkbox field of 'checkbox'.
function btnPayCard() { $('.checkbox input').prop('Yes', true); } function btnPayCash() { $(.'checkbox input').prop('No', true); }
Any help or suggestions would be appreciated!