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});
在评论后添加获得btnID后,您可以找到要使用的查找器浏览,例如:
var $browser;
switch(btID)
{
case 'open':
$browser = $('#finder_browse');
break;case 'open1':
$browser = $('#finder_browse1');
break;
等。。}
相关文章:
- d3.js用按钮更新条形图工具提示
- 选择单选按钮更新2个输入字段
- 使用带角度的单选按钮更新不同的模型
- 通过 JavaScript 从主网格视图上的功能区按钮更新 CRM 2011 中的字段
- 如何在AngularJS中使用单个按钮更新列
- 使用js使html按钮更新选择标记onchange函数
- 在Javascript中刷新按钮更新Accordion
- 使用复选框和按钮更新<视频> src
- 使用按钮更新滑块 UI 值
- Elfinder文件管理器,带有多个按钮更新文本输入
- 如何通过单击按钮更新计数器和替换文本
- 按钮更新节点.js和 HTML
- 如何在 Meteor 中使用多个输入字段和单个更新按钮更新文档
- 使用按钮更新数据库行
- 如何在Javascript中通过点击按钮更新里程计值
- 使用angular js和单选按钮更新html表中的数据
- 通过点击html按钮更新html页面上的javascript变量
- 显示空白图表,然后使用按钮更新(谷歌图表)
- 如何通过按钮更新HTML文本
- 使用下拉按钮更新choropleth地图