jquery – CF7 Populate Text Field Based On Checkbox Checked

Question

I need to be be able to auto populate a text field with “one-hidden” when a customer checks a checkbox but so far examples I’ve found online do not seem to work or im putting them in the wrong place.

$('#flight-include').change(function(){
    $("#one-control").text("");
    if ($('#flight-include').is(':checked')) { 
        $("#one-control").text("one-hidden"); 
    }
});

I put the above in the function file and it did nothing so guessing im doing something wrong or missing something.

flight-control is the checkbox, one-control is the text field. “one-hidden” is the text that needs to appear in the text field when the flight-include box is checked.

Can someone help as im pretty clueless with this type of coding. Many thanks

Tried executing the code above in the function file but possible not the right place.

0
Tom Kidd 2 weeks 2023-05-13T11:38:30-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse