I'm sure this has been addressed elsewhere, but I've read 20+ stackoverflow entries trying to find an answer, but all the ones I've read don't address this exactly and when I try to adopt proposed solutions, they just don't work. I'm having issues with unchecked checkboxes in Mad Libs returning a value of "undefined," so that the code below returns the following (if, for example, #check3 is checked and the other two are not):
In the end, their success can be contributed entirely to their undefined, undefined, dedicated [#noun-2 value, which is working just fine].
var $end = " In the end, their success can be contributed entirely to their " + $('#check1:checked').val() + ", " + $('#check2:checked').val() + ", " + $('#check3:checked').val() + " " + $('#noun-2').val() + ".";
Any idea of how I can return the values of only checked checkboxes? Do I need to write an if/else to make this happen?
Thank you.
Aucun commentaire:
Enregistrer un commentaire