Hey all,
I'm having a problem with jQuery that I thought would be simple, but I still haven't found a solution.
I have an upload form for users to upload images in WordPress, and when a user clicks "insert into post" the url of the uploaded image is supposed to go into a text input field.
I can get 1 to work fine, but when I have multiple upload buttons with multiple input fields the image url is send to the last text input only.
Here's my code:
<script type="text/javascript">
//MEDIA UPLOADER
jQuery(document).ready(function() {
//Opens the upload dialog box when the button is clicked
jQuery('#wpsa_slide_<?php echo $slidenumber; ?>_button').click(function() {
formfield = jQuery('#wpsa_slide_<?php echo $slidenumber; ?>').attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
//Sends the uploaded/selected file URL to the text input field
window.send_to_editor = function(html) {
imgurl = jQuery('img',html).attr('src');
jQuery('#wpsa_slide_<?php echo $slidenumber; ?>').val(imgurl);
tb_remove();
}
});
</script>