开发者

wordpress upload form javascript help

I have a custom template with custom admin panel, I have a image uploader using the wordpress media uploader in lightbox.

Here is the structure:

textbox 1 - browse 1
textbox 2 - browse 2
textbox 3 - browse 3

If I click on browse 1, the popup apears and if i click "insert into post" the lightbox media uploader will disappear and return a image url.

But the problem is the url appends n the 3 textbox and i only click on browse 1,. My expected result is if i click browse 1 it should be append in textbox 1 and so on.

Here is my code

jQuery('.op_upload_image_button').each(function() {
    jQuery(this).click(function() {
        formfield = jQuery(this).parent().find('.op_upload_image').attr('name');
        tb_show('', 'media-upload.php?type=image&TB_iframe=true');
        return false;
    });
    window.send_to_editor = function(html) {
        imgurl = jQuery('img',html).开发者_StackOverflow社区attr('src');
        jQuery('.op_upload_image').val(imgurl);
        tb_remove();
    }
});


Not sure from the question, but I wonder if this is because all three of the textboxes are .op_upload_image and this bit jQuery('.op_upload_image').val(imgurl); is referencing the last textbox?


jQuery('.op_upload_image_button3').click(function() {
    jQuery(this).click(function() {
        formfield = jQuery(this).parent().find('.op_upload_image3').attr('name');
        tb_show('', 'media-upload.php?type=image&TB_iframe=true');
        return false;
    });

    window.send_to_editor = function(html) {
        imgurl = jQuery('img',html).attr('src');
        jQuery('.op_upload_image3').val(imgurl);
        tb_remove();
    }
});

Just change class name for button and text field class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜