mardi 8 mai 2018

how do I change the image of several buttons, via boolean in laravel?

how do I change the images of buttons, only with values of 0 and 1 ( $table -> boolean('alugado');) of a database eloquent in laravel?

I want to retrieve the boolean values from my table and change the images in my view buttons

Is it possible to use asset in laravel?

my buttons

                        <div class="inputbutton">
                        <span class="text">text_1</span>
                        <input type="submit" class="btTxt submit" value=""  id="text_1" onclick="reply_click(this.id)">
                        </div>
                        <div class="inputbutton">
                        <span class="text">text_2</span>
                        <input type="submit" class="btTxt submit" value=""  id="text_2" onclick="reply_click(this.id)">
                        </div>                        
                        <div class="inputbutton">
                        <span class="text">text_3</span>
                        <input type="submit" class="btTxt submit" value=""  id="text_3" onclick="reply_click(this.id)">
                        </div>
                        <div class="inputbutton">
                        <span class="text">text_4</span>
                        <input type="submit" class="btTxt submit" value=""  id="text_4" onclick="reply_click(this.id)">
                        </div>
                        <div class="inputbutton">
                        <span class="text">text_5</span>
                        <input type="submit" class="btTxt submit" value=""  id="text_1" onclick="reply_click(this.id)">
                        </div>

my ajax

 function reply_click(clicked_id){
$(function() {
    $.ajaxSetup({
       headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
       }
    });
    console.log('attached');
    $('#openButton').on('click', function(data) {
        console.log('clicked');
        $.ajax({
          type: "POST",
          url: "/dash",
            data: { _token: $('meta[name="csrf-token"]').attr(('src',''+data))}
        })
       .done(function(data){
            console.log(data);
            $('.inputbutton input').css("background-image", ",''("+data+")");
        })
        .fail(function(data){
            console.log('Error:', data);
        });
    });
});
};

my css file

div.inputbutton input {
background: url('/img/MYimg.png') no-repeat;
cursor: pointer;
width: 100px;
height: 130px;
border: none;
background-size: 100%;
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire