Show DevBest Preview Image When Click Button

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
Hey, really quick release from me.
When you want to post an article you'd see if image link is right or not, right?
So, use this code below:
Code:
<label for="img">Image Link.</label>
<input type="text" id="img" class="form-control" placeholder="Image link.">
<a class="btn btn-primary btn-large"  id="button"name="button">Preview Image</a>

 <script type="text/javascript">
        document.getElementById('button').onclick = function() {
            var val = document.getElementById('img').value,
                src =  val ,
                img = document.createElement('img');
            
            img.src = src;
            document.body.appendChild(img);
        }
    </script>
Enjoy, cheers!
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Wouldn't you want a dropdown list for something like this? The select the image, and when they change the dropdown the image updates automatically (No need to click a button)?

Nice release anyway.
 

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
Wouldn't you want a dropdown list for something like this? The select the image, and when they change the dropdown the image updates automatically (No need to click a button)?

Nice release anyway.
Nice idea, but my site is a food sharing site so they'd upload their own image and if I do it they could not find their food soo .
Nice idea tho. I will think about this
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,128
2,456
What if they gave up the wrong link and want to do it again, this will stack the inputs instead of replacing the existing one.
 

Users who are viewing this thread

Top