我有一个带有价格计算器的表单,虽然我能够使用jQuery脚本设置所有文本字段等,但我无法弄清楚如何在该jQuery脚本中设置变量页面上另一个Javascript中的价格计算器。
有一个id为#price_draftarticles的文本字段,我设置了一个值 - 这有效,但我还有一个名为price_draftarticles的变量,它被添加到其他变量中以创建总计。我引用了我的Form_Calculator()函数,但它仍未更新总数。
相关表格代码
<div class="col-sm-8">
<div class="radio">
<label>
<input class="structype" type="radio" name="CorpStructure" id="price_structureop3" value="I want to provide my own structure" onClick="checkRadioCS(); Form_Calculator();"><strong>I want to provide my own structure</strong>
</label>
</div>
</div>
<div class="row">
<div class="col-sm-8">
<div class="checkbox">
<label>
<input name="DraftArticles" type="checkbox" id="DraftArticles" onClick="checkRadioTF(); Form_Calculator();" value="Yes">DETAILS
</label>
</div>
</div>
<div class="col-xs-4 col-sm-2">
<input name="price_draftarticles" type="text" class="form-control fcalc" id="price_draftarticles" value="" readonly>
</div>
</div>
我的jquery函数
<script>
$(function () {
$('.structype').change(function () {
if ($(this).val() === 'I want to provide my own structure')
{
$("#DraftArticles").prop("checked", true);
$("#price_draftarticles").val('$25.00');
$("price_draftarticles").val('25.00');
$('#CustomStructureDetail').show('500');
}
if ($(this).val() == 'Standard structure template one class of shares') {
$('#CustomStructureDetail').hide('500');
}
if ($(this).val() == 'Two classes of shares') {
$('#CustomStructureDetail').hide('500');
}
});
checkRadioTF();
checkCheckBox();
Form_Calculator();
checkeFileJur();
});
</script>
答案 0 :(得分:0)
看起来你忘记了
中的'#'字符$("price_draftarticles").val('25.00');
这应该是
$("#price_draftarticles").val('25.00');
答案 1 :(得分:0)
正如@BYates所说,选择器错过了'#'for price_draftarticles。
$("#price_draftarticles").val('25.00');
但是如果您尝试使用名称来获取/设置输入值。选择器应该是这样的:
$('input[name="price_draftarticles"]').val('25.00')