1

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.

nod
  • 33
  • 5

1 Answers1

0

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

AmirAli Esteki
  • 542
  • 3
  • 13
  • now i use javasript like this . new the problem is i want to stay at same page, i added href="javascript:void(0)", yes it make me stay in the sampe page but for a while and then automatically redirect to another page. – nod Sep 07 '20 at 23:51
  • add http:// at first of image link in onclick event. what's happened ? your problem solved ? – AmirAli Esteki Sep 07 '20 at 23:52
  • new the problem is i want to stay at same page, i added href="javascript:void(0)", yes it make me stay in the same page but for a while and then automatically redirect to another page. – nod Sep 07 '20 at 23:55