我有两个图像按钮是禁用,我希望在fileupload控件中有文件时启用它。我搜索他们将有一个按钮的在线资源。但是,如果用户选择了一个文件并且两个图像按钮都会提示,我怎么能这样做呢? 你的答案和评论将被评论。
下面的代码是javascript代码。
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import static org.elasticsearch.node.NodeBuilder.*;
public class Els {
public static void main (String args[]){
Els p = new Els();
p.postElasticSearch();
}
public static Map<String, Object> putJsonDocument(String title, String content, Date postDate, String author){
Map<String, Object> jsonDocument = new HashMap<String, Object>();
jsonDocument.put("title", title);
jsonDocument.put("content", content);
jsonDocument.put("postDate", postDate);
jsonDocument.put("author", author);
return jsonDocument;
}
Node node = nodeBuilder().clusterName("elasticsearch").client(true).node();
Client client = node.client();
private void postElasticSearch(){
client.prepareIndex("testindex", "article")
.setSource(putJsonDocument("Example Title",
"This description is so important. You dont even know!",
new Date(),
"J.R."))
.execute().actionGet();
node.close();}
}
按照asp.net代码。
<script>
function fnCallback() {
$("#ImageButton2").show();
}
</script>
答案 0 :(得分:0)
您可以从客户端进行,
通过在filecontrol onChange
事件
<asp:FileUpload ID="FileUpload1" runat="server" onChange='fnCallback();' />
<asp:ImageButton ID="ImageButton1" runat="server" style="display:none;"
ImageUrl="~/imagePath" />
function fnCallback() {
// $("#ImageButton1").show(); In jQuery
document.getElementById("ImageButton1").style.display = "block"; // In JavaScript
}
答案 1 :(得分:0)
function importMember(courseSelectImport,value){
if ( courseSelectImport && value) {
jQuery('#csvsubmite').attr('disabled',false);
jQuery( '#csvsubmite' ).addClass( "importbtn" );
} else {
jQuery('#csvsubmite').attr('disabled',true);
jQuery('#csvsubmite' ).removeClass( "importbtn" );
}
}
jQuery('input:file').change(function(){
let value = jQuery(this).val();
let courseSelectImport = jQuery('#courseSelectImport').val();
importMember(courseSelectImport,value);
});
jQuery('#courseSelectImport').on('change',function(){
let courseSelectImport = jQuery(this).val();
let fileVal = jQuery('input:file').val();
importMember(courseSelectImport,fileVal);
});
<label class="col-md-4 mb-0 text-right">Course</label>
<select name="courseSelectImport" id="courseSelectImport" class="custom-select">
<option value="">All</option>
</select>
<input type='file' name='membercsv' accept=".csv">
<input type='submit' name='submit' id="csvsubmite" value='Import' disabled>