文本更改时,输入框会自动更新接下来的6个文本框 [英] when text changed inputbox automatically updates next 6 text boxes
问题描述
我有7个文本框.如果更改了前1个文本框(所有年份的音量)文本,则需要在接下来的6个输入框中将文本更新(最新的2009年音量为2014年最新的音量).我需要为此使用javascript或jQuery.我将为前1个文本框编写Js textchanged()或focuschange().那我应该在focuschage()或textchanged methods()中写什么
I have 7 textboxes. If Top 1 textbox(Volume All Years) text changed, text need to be updated in next 6 inputboxes(Latest 2009 Volume to Latest 2014 Volume). I need javascript or Jquery for this. I will write Js textchanged() or focuschange() for top 1 textbox. So what should I write in focuschage() or textchanged methods()
<tr id="row12_136" class="RegText">
<td style="width:420px;Padding-right:20px;">Volume All Years</td>
<td style="width:420px;Padding-left:0px;">
<input name="12_136" type="text" maxlength="255" id="12_136" tabindex="61" title="Volume All Years" class="textbox" OnKeyPress="javascript:FocusChange();" style="width:300px;" />
</td>
</tr><tr id="row12_60" class="RegText">
<td style="width:420px;Padding-right:20px;">Latest 2009 Volume*</td>
<td style="width:420px;Padding-left:0px;">
<input name="12_60" type="text" maxlength="255" id="12_60" tabindex="62" title="Latest 2009 Volume" class="textbox" OnKeyPress="javascript:FocusChange();" style="width:300px;" />
<span controltovalidate="12_60" errormessage="* Required!" display="Dynamic" validationGroup="ValidateInsert" id="_ctl47" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;display:none;">* Required!</span>
</td>
</tr><tr id="row12_61" class="RegText">
<td style="width:420px;Padding-right:20px;">Latest 2010 Volume*</td>
<td style="width:420px;Padding-left:0px;">
<input name="12_61" type="text" maxlength="255" id="12_61" tabindex="63" title="Latest 2010 Volume" class="textbox" OnKeyPress="javascript:FocusChange();" style="width:300px;" />
<span controltovalidate="12_61" errormessage="* Required!" display="Dynamic" validationGroup="ValidateInsert" id="_ctl48" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;display:none;">* Required!</span>
</td>
</tr><tr id="row12_62" class="RegText">
<td style="width:420px;Padding-right:20px;">Latest 2011 Volume*</td>
<td style="width:420px;Padding-left:0px;">
<input name="12_62" type="text" maxlength="255" id="12_62" tabindex="64" title="Latest 2011 Volume" class="textbox" OnKeyPress="javascript:FocusChange();" style="width:300px;" />
<span controltovalidate="12_62" errormessage="* Required!" display="Dynamic" validationGroup="ValidateInsert" id="_ctl49" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;display:none;">* Required!</span>
</td>
</tr><tr id="row12_63" class="RegText">
<td style="width:420px;Padding-right:20px;">Latest 2012 Volume*</td>
<td style="width:420px;Padding-left:0px;">
<input name="12_63" type="text" maxlength="255" id="12_63" tabindex="65" title="Latest 2012 Volume" class="textbox" OnKeyPress="javascript:FocusChange();" style="width:300px;" />
<span controltovalidate="12_63" errormessage="* Required!" display="Dynamic" validationGroup="ValidateInsert" id="_ctl50" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;display:none;">* Required!</span>
</td>
</tr><tr id="row12_64" class="RegText">
<td style="width:420px;Padding-right:20px;">Latest 2013 Volume*</td>
<td style="width:420px;Padding-left:0px;">
<input name="12_64" type="text" maxlength="255" id="12_64" tabindex="66" title="Latest 2013 Volume" class="textbox" OnKeyPress="javascript:FocusChange();" style="width:300px;" />
<span controltovalidate="12_64" errormessage="* Required!" display="Dynamic" validationGroup="ValidateInsert" id="_ctl51" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;display:none;">* Required!</span>
</td>
</tr><tr id="row12_65" class="RegText">
<td style="width:420px;Padding-right:20px;">Latest 2014 Volume*</td>
<td style="width:420px;Padding-left:0px;">
<input name="12_65" type="text" maxlength="255" id="12_65" tabindex="67" title="Latest 2014 Volume" class="textbox" OnKeyPress="javascript:FocusChange();" style="width:300px;" />
<span controltovalidate="12_65" errormessage="* Required!" display="Dynamic" validationGroup="ValidateInsert" id="_ctl52" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;display:none;">* Required!</span>
</td>
推荐答案
使用该html,其中#foo
是在相应表上零输入的选择器:
With that html, and where #foo
is a selector to zero in on the appropriate table:
$('tr.RegText input:eq(0)').change(function() {
$('tr.RegText input:gt(0):lt(7)').val($(this).val());
});
这假设第一输入字段的模糊变化是可以接受的.更改为键盘或其他口味.
This assumes that change on blur of the first input field is acceptable. Change to keyup or whatever to taste.
这篇关于文本更改时,输入框会自动更新接下来的6个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!