mardi 3 février 2015

js checkbox NOT set a custom value if not checked

I am working on a form that someone else created that passes through information to Salesforce. But regardless of where it sends values to, the checkbox doesnt seem to behave as it should. No matter checking or unchecking the checkbox, it will always output the 'xxx' value.


The javascript sets the value of another checkbox inside salesforce based on the first checkbox. If that checkbox is checked, set the 'optin' value to true, if not false.


I feel I need another line of code that says: if checkbox is checked then value=xxx. if not checked, nothing. Then based on that, the other if else can be run.


here is the html:



<input type="checkbox" value="xxx" id="industry_optin" name="industry_optin"> YES


This is the js: (it is part of a bigger part of js, so there is no close bracket)



$(document).ready(function() {

$('#industry_optin').on('change', function() {
if ($(this).prop('checked') === true) {
$('#optin').prop('checked', true);
} else {
$('#optin').prop('checked', false);
}
});




Aucun commentaire:

Enregistrer un commentaire