vivek kumar
vivek kumar

Reputation: 55

how to check If checkbox is checked or not laravel 5.4

I want to show a button if checkbox gets checked and if not checked button will not appear in laravel 5.4. How can I do this.

Upvotes: 1

Views: 3719

Answers (3)

Sagynbek Kenzhebaev
Sagynbek Kenzhebaev

Reputation: 360

Or you can verify if checkbox is checked in BackEnd

if($request['checkBoxName'])
    return "Checkbox is checked";
else 
    return "Checkbox is not checked";

Upvotes: 0

Gohel Dhaval
Gohel Dhaval

Reputation: 820

you can do this by using jquery

$('#checkbox').change(function(){
        if($('#checkbox').is(':checked')){
    console.log("asdad");
        $('#button').css('display','inline');
    }else{
        $('#button').css('display','none');
    }
})

Upvotes: 1

Touhidur
Touhidur

Reputation: 215

Suppose you html

<input type="checkbox" name="checkbox" id="checkbox">

In front-end you can check using jQuery

if ($('#checkbox').is(':checked')){
   //
}

In back-end you can check using:

if (isset($request->checkbox) {
     //
}

Upvotes: 3

Related Questions