简体   繁体   中英

How can I select an image and put the link of the image in a textbox?

I have a form SelectIamge.php which includes the following html:

<input type="text" id="urlImage" />
<input type="button" id="selectImage" />

The user needs to be able to click the selectImage button to open a popup of page UploadImage.php. The user will then upload a image and a thumbnail of that image will be displayed. If the user clicks on the thumbnail, I need to put the url of the image in the urlImage textbox.

Can someone help me solve this problem?

First of all give some id to thumbnail image ie id='thumb'

Include jquery library file and write below javascript in the file

<script type="text/javascript">
$("#thumb").click(function(){
   var src = $(this).attr('src');
   $("#urlImage").val(src);
});
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM