how to change value into null when click delete button on jasnybootstrap

110 Views Asked by At

hallo i try to change value when i click delete button in jasnybootstrap but the delete button is not working.

<div class="fileinput fileinput-new" data-provides="fileinput">
        <div class="fileinput-new thumbnail" style="width: 200px; height: 125px;">
        @if($post->image == NULL)
        <img src="{{ $post->image_url ? $post->image_url : 'http://placehold.it/200x150&text=no+image' }}" alt="...">
        @elseif($post->image != NULL)
        <img src="{{ $post->image_url}}" alt="...">
        @endif
    </div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
<div>
    <span class="btn btn-default btn-file"><span class="fileinput-new">Choose Image</span><span class="fileinput-exists">Change</span><input type="file" name='image'></span>
    <span><a href="#" class="btn btn-default fileinput-new" onclick="(( $post->image==NULL))">Delete</a></span>
    <span><a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Delete</a></span>
</div>
</div>

how to write the code like this logic

onclick="(( $post->image==NULL))"

and then the display picture show null or back to default

'http://placehold.it/200x150&text=no+image'

the delete button works when i click change button for change the picture first, then i click delete button, the picture change to value picture before. nah i dont want like this, i want after click delete button the picture change into default picture. help me please.

1

There are 1 best solutions below

3
On

if you wanna delete the image after clicking on delete button, you have 2 ways:

1 - redirecting client to another page for processing delete method

2 - use ajax request to delete image

but if you wanna only change the image when click on delete button, you should change the src attr with javascript.

and at last your question is very very comprehensive and can't solved with a single line code