mardi 12 juillet 2022

Populate textarea if checkbox is checked

I'm using this to populate a textarea with value if a checkbox is checked:

$('#checkbox_a').change(function(){
    $("#textarea_b").text("");
    if ($('#checkbox_a').is(':checked')) { 
        $("#textarea_b").text("Yes"); 
    }
});

The problem I'm having is that if a user already inputs something in the textarea, decides to delete his input again and marks the checkbox afterwards it won't get populated anymore.

Can you help me with that?




Aucun commentaire:

Enregistrer un commentaire