English 中文(简体)
包含多个按钮的 Elfinder 文件管理器, 更新文本输入
原标题:Elfinder filemanager with multiple buttons updating text input

每个按钮都在更新元素 :

<input type="text" id="field" name="image" value="<?php echo @$DuzenleSonuc[0][ image ]; ?>" />

我想对内容进行这样的更新:

  onclick open -> update field
  onclick open1 -> update field1
  onclick open2 -> update field2
  onclick open3 -> update field3
  onclick open4 -> update field4

现在的情况和下面完全一样,我哪里错了?

  onclick open -> updates field
  onclick open1 -> updates field
  onclick open2 -> updates field
  onclick open3 -> updates field
  onclick open4 -> updates field

我的代码如下:

<script type="text/javascript" charset="utf-8">
    $().ready(function() {
        var opt = {// Must change variable name
            url :  elfinder/connectors/php/connector.php ,
            lang :  tr ,
            editorCallback : function(url) {document.getElementById( field ).value=url;},// Must change the form field id
            closeOnEditorCallback : true,
            docked : false,
            dialog : { title :  Dosya Yöneticisi , height: 500 },
        }

        $( #open ).click(function() {// Must change the button s id
            $( #finder_browse ).elfinder(opt)// Must update the form field id
            $( #finder_browse ).elfinder($(this).attr( id )); // Must update the form field id
        })

        $( #open1 ).click(function() {// Must change the button s id
            $( #finder_browse1 ).elfinder(opt)// Must update the form field id
            $( #finder_browse1 ).elfinder($(this).attr( id )); // Must update the form field id
        })
        $( #open2 ).click(function() {// Must change the button s id
            $( #finder_browse2 ).elfinder(opt)// Must update the form field id
            $( #finder_browse2 ).elfinder($(this).attr( id )); // Must update the form field id
        })
        $( #open3 ).click(function() {// Must change the button s id
            $( #finder_browse3 ).elfinder(opt)// Must update the form field id
            $( #finder_browse3 ).elfinder($(this).attr( id )); // Must update the form field id
        })
        $( #open4 ).click(function() {// Must change the button s id
            $( #finder_browse4 ).elfinder(opt)// Must update the form field id
            $( #finder_browse4 ).elfinder($(this).attr( id )); // Must update the form field id
        })
    });
    $(document).ready(function(){
        $( .taslak ).click(function(){
            $( #k ).val("Taslak");
        });
    })
</script>
<!-- elFinder -->
<div class="textbox left">
    <h2>Ürün Resimleri</h2>

    <div class="textbox_content">
        <p class="fileupload">
            <label>Ürün Ana Resmi:</label>
        <div id="finder_browse"></div>
        <input type="text" id="field" name="image" value="<?php echo @$DuzenleSonuc[0][ image ]; ?>" />
        <input type="button" id="open" class="file" value="Resim Seç" />
        </p>
        <hr />
        <p class="fileupload">
            <label>Ürün Resmi:</label>
        <div id="finder_browse1"></div>
        <input type="text" id="field1" name="image1" value="<?php echo @$DuzenleSonuc[0][ image1 ]; ?>" />
        <input type="button" id="open1" class="file" value="Resim Seç" />
        </p>
        <p class="fileupload">
            <label>Ürün Resmi:</label>
        <div id="finder_browse2"></div>
        <input type="text" id="field2" name="image2" value="<?php echo @$DuzenleSonuc[0][ image2 ]; ?>" />
        <input type="button" id="open2" class="file" value="Resim Seç" />
        </p>
        <p class="fileupload">
            <label>Ürün Resmi:</label>
        <div id="finder_browse3"></div>
        <input type="text" id="field3" name="image3" value="<?php echo @$DuzenleSonuc[0][ image3 ]; ?>" />
        <input type="button" id="open3" class="file" value="Resim Seç" />
        </p>
        <p class="fileupload">
            <label>Ürün Resmi:</label>
        <div id="finder_browse4"></div>
        <input type="text" id="field4" name="image4" value="<?php echo @$DuzenleSonuc[0][ image4 ]; ?>" />
        <input type="button" id="open4" class="file" value="Resim Seç" />
        </p>
    </div>
</div> 
最佳回答

在全部按钮中添加相同的类, 并只添加一个点击事件, 例如 :

$( .btnClass ).click(function(){
var btnID = $(this).attr( id ); // Btn id clicked
// Process ckick event
});

或如果所有按钮都打开了启动 ID, 您可以让点击事件像

$( input[id^=open] ).click(function(){    var btnID = $(this).attr( id ); // Btn id clicked});

add after your comment once you get the btnID you can find which finder-browse to use somethign like:

var $browser;
switch(btID)
{
case  open :
$browser = $( #finder_browse );
break;case  open1 :
$browser = $( #finder_browse1 );
break;

etc.. }

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签