简体   繁体   English

如何选择图像并将图像的链接放在文本框中?

[英]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: 我有一个SelectIamge.php表单,其中包含以下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. 用户需要能够单击selectImage按钮以打开页面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. 如果用户单击缩略图,则需要将图像的URL放在urlImage文本框中。

Can someone help me solve this problem? 有人可以帮我解决这个问题吗?

First of all give some id to thumbnail image ie id='thumb' 首先给缩略图添加一些ID,即id ='thumb'

Include jquery library file and write below javascript in the file 包含jquery库文件,并在文件中的javascript下面写

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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