父窗体和子窗体在选中的javascript上显示值

父窗体和子窗体在选中的javascript上显示值,javascript,php,jquery,forms,Javascript,Php,Jquery,Forms,我有一个包含多个表单的网页,每个表单都有一个不同的表单id。我需要java脚本在选中框时在字段中显示一个字符串。这适用于第一个表单,不适用于页面上的其他表单 网页编码: <div class="form" id="form-products_483"><form id="products_483" name="products_483" enctype="application/x-www-form-urlencoded" method="post" jshandler=""

我有一个包含多个表单的网页,每个表单都有一个不同的表单id。我需要java脚本在选中框时在字段中显示一个字符串。这适用于第一个表单,不适用于页面上的其他表单

网页编码:

<div class="form" id="form-products_483"><form id="products_483"  name="products_483" enctype="application/x-www-form-urlencoded" method="post" jshandler="" action="">
<div class="form-element hidden" id="form-element-id__483">
<input type="hidden" name="id__483" value="483" class="p_id" id="id__483"></div>

<div class="product-form-element text" id="form-element-v_one_fees_cost_f"> <label for="v_one_fees_cost_f" class="form-element-label optional">$ of one-time fixed fee</label>

<input type="text" name="v_one_fees_cost_f" id="v_one_fees_cost_f" value="" maxlength="9" class="v_one_fees_cost_f" placeholder="xx.xx"></div>
<div class="product-form-element checkbox" id="form-element-v_varies"><label for="v_varies" class="form-element-label optional">Varies</label>

<input type="hidden" name="v_varies" value="0"><input type="checkbox" name="v_varies" id="v_varies" value="1" checked="checked"></div>

注意:我对java脚本一无所知。即使你能告诉我一些教程。这将非常有帮助。

将ID更改为类,这将起作用将ID更改为类,这将起作用
$(document).on('change', '#v_one_fees_f', function(e) {
block_($(this).parents('form').find('.v_one_fees_cost_f'), $(this).val());
if($(this).val() != 'Yes') {
    $(this).parents('form').find('#v_varies').attr('disabled', 'disabled');
}
else {
    $(this).parents('form').find('#v_varies').removeAttr('disabled');
}
});

$(document).on('change', '#v_varies', function(e) {
inputVaries($("#v_one_fees_cost_f"), $(this));
});


function inputVaries(form_input, checkbox){
   if (checkbox.is(':checked')) {
       form_input.val("Varies");
  }
  else{
    form_input.val("");
  }
}