0
我遇到了jQuery的問題,我認爲這很簡單,但我仍然沒有找到解決方案。jQuery - 將多個URL發送到多個文本輸入字段
我有一個上傳表單供用戶在WordPress上傳圖片,當用戶點擊「插入後」時,上傳圖片的網址應該進入文本輸入框。
我可以得到1工作正常,但是當我有多個輸入字段的多個上傳按鈕時,圖像url只發送到最後一個文本輸入。
這裏是我的代碼:
<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>
謝謝...有沒有分配一個ID或類,使其獨特的方式,或是否有更好的方式來處理這個問題? – Nathan 2010-08-31 15:25:08
實際上,我得到了正確的圖像url,但是例如如果我有3個輸入字段,並且我希望圖像url轉到第二個輸入字段,那麼將新的url傳遞給第三個字段...希望這是有道理的:) – Nathan 2010-08-31 16:05:58
你可以發佈你的HTML代碼片段嗎? – mamoo 2010-08-31 20:14:50