- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个通过 Ajax 提交的表单。用户发送表单后,文本会发生变化,显示数据已成功发送,然后显示已填写的表单。我想显示表单,但我不希望他们重新提交表单,因此我想禁用输入和提交按钮。我有3个操作,添加、更新和查看。禁用 View 中的表单输入后,在添加中保持禁用状态。
<div id="userModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="user_form" enctype="multipart/form-data">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Report</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-2">
<label for="ex1">Square</label>
<input type="text" name="square" id="square" class="form-control">
</div>
<div class="col-xs-2">
<label for="ex1"> Number </label>
<input type="text" name="report_number" id="report_number" class="form-control">
</div>
<div class="col-xs-4">
<label>Report Date </label>
<input type="date" name="report_date" id="report_date" class="form-control" />
</div >
</div>
</br>
<div class="row">
<div class="col-xs-12">
<label>Notes </label>
<textarea rows="15" cols="80" type="text" name="notes" id="notes" class="form-control" > </textarea>
</div >
</div>
<br />
<label>Select Image</label>
<input type="file" name="user_image" id="user_image" />
<span id="user_uploaded_image"></span>
</div>
<div class="modal-footer">
<input type="hidden" name="report_id" id="report_id" />
<input type="hidden" name="operation" id="operation" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</form>
</div>
</div>
<script>
$(document).on('submit', '#user_form', function(event){
event.preventDefault();
var addedSquare = $('#square').val();
var addedNumber = $('#report_number').val();
var addedDate = $('#report_date').val();
var extension = $('#user_image').val().split('.').pop().toLowerCase();
if(extension != '')
{
if(jQuery.inArray(extension, ['gif','png','jpg','jpeg']) == -1)
{
alert("Invalid Image File");
$('#user_image').val('');
return false;
}
}
if(addedSquare != '' && addedNumber != '')
{
$.ajax({
url:"insert.php",
method:'POST',
data:new FormData(this),
contentType:false,
processData:false,
success:function(data)
{
alert(data);
$('#user_form')[0].reset();
$('#userModal').modal('hide');
dataTable.ajax.reload();
}
});
}
else
{
alert("Both Fields are Required");
}
});
$(document).on('click', '.update', function(){
var report_id = $(this).attr("id");
$.ajax({
url:"fetch_single.php",
method:"POST",
data:{report_id:report_id},
dataType:"json",
success:function(data)
{
$('#userModal').modal('show');
$('#square').val(data.square).prop( "disabled", false );
$('#report_number').val(data.report_number).prop( "disabled", false );
$('#report_date').val(data.report_date).prop( "disabled", false );
$('.modal-title').text("Edit Report");
$('#report_id').val(report_id);
$('#user_uploaded_image').html(data.user_image);
$('#action').val("Edit");
$('#operation').val("Edit");
}
})
});
$(document).on('click', '.view', function(){
var report_id = $(this).attr("id");
$.ajax({
url:"fetch_single.php",
method:"POST",
data:{report_id:report_id},
dataType:"json",
success:function(data)
{
$('#userModal').modal('show');
$('#square').val(data.square).prop( "disabled", true );
$('#report_number').val(data.report_number).prop( "disabled", true );
$('#report_date').val(data.report_date).prop( "disabled", true );
$('.modal-title').text("View Report");
$('#report_id').val(report_id);
$('#user_uploaded_image').html(data.user_image);
$('#action').val("View");
$('#operation').val("View");
}
})
});
</script>
如何在 add 中再次启用输入?
最佳答案
只是 .prop( "disabled", false );
关于javascript - 如何在将表单输入的属性设置为 "false"后将其更改为禁用 = "true",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43450406/
这个问题在这里已经有了答案: Why in Python does "0, 0 == (0, 0)" equal "(0, False)"? (7 个回答) 去年关闭。 代码片段 1: a = Tru
Integer i = 127; Integer j = 127; System.out.println(i == j); System.out.println(i.equals(j)); Integ
我试图用 Python 进行类似下面的代码的比较,但对产生的输出感到困惑。 谁能解释为什么输出是这样的? >>> True, True == True, True (True, True, True)
我们的下拉值是动态的 010100。 你能帮我将这些值转换为 true、false 吗? Offer的值是10100,Reject的值是10111。所以这些需要转换成 10100 = true,fal
我正在测试,如果用户在页面顶部显示一种货币“EUR”和另一种货币“GBP”,那么我期望包含文本“EUR”和页面下方还存在另一个包含文本“GBP”的链接。它包含在一个名为 "nav-tabs au-ta
如何检查数组的所有元素是真值还是假值。 因为以下内容似乎没有做到这一点:_.all([true, true, true], true); 它返回:false? 最佳答案 您应该重新阅读_.every(
C#:我有一个如下所示的字符串变量: string a = "(true and true) or (true or false)"; 这可以是任何东西,它可以变得更复杂,比如: string b
ruby : true == true == true syntax error, unexpected tEQ 对比JavaScript: true == true == true // => tr
这个问题已经有答案了: Equality of truthy and falsy values (JavaScript) (3 个回答) Which equals operator (== vs ==
为什么 R 中的 TRUE == "TRUE" 是 TRUE? R 中是否有与 === 等效的内容? 更新: 这些都返回FALSE: TRUE == "True" TRUE == "true" TRU
简单的查询,可能不可能,但我知道那里有一些聪明的人:) 给定一个 bool 参数,我希望定义我的 where 子句来限制特定列的输出 - 或不执行任何操作。 因此,给定参数@bit = 1,结果将是:
编写 Excel 公式时,将值设置为 true、“true”还是 true() 是否有区别? 换句话来说,以下哪一个是最好的?还是要看具体情况? if (A1 = 1, true, false) if
如果我们评估这个:TRUE AND TRUE,为什么会这样? 'yes' : 'no' 等于 TRUE 但不等于 yes 何时评估:(TRUE AND TRUE) ? 'yes' : 'no' 等于
这个问题在这里已经有了答案: Behaviour of and operator in javascript [duplicate] (1 个回答) 关闭 7 年前。 如题所说,我不太明白为什么(t
我有一个包含 FromDate 、 ToDate 、 VendorName 和 GoodsName 的表单,一旦一切为真,我需要显示结果 示例: FromDate="11/20/2019"、ToDat
我最近参加了 Java 的入门测试,这个问题让我很困惑。完整的问题是: boolean b1 = true; boolean b2 = false; if (b2 != b1 != b2) S
我有一个模型,我有: ipv4_address = models.IPAddressField(verbose_name=_('ipv4 address'), blank=True, null=Tru
False in [True,True] False in pd.Series([True,True]) 第一行代码返回False第二行代码返回 True! 我想我一定是做错了什么或者遗漏了什么。当我
我可以在 Coq 中证明以下内容吗? Lemma bool_uip (H1 : true = true): H1 = eq_refl true. 即true = true 的所有证明都相同吗? 例如
如果我的理解是正确的,他们做的事情完全一样。为什么有人会使用“for”变体?仅仅是味道吗? 编辑:我想我也在考虑 for (;;)。 最佳答案 for (;;) 通常用于防止编译器警告: while(
我是一名优秀的程序员,十分优秀!