[英]Display Form input in additional Text field
I am trying to have a contract filled in with values from a form on the same page, I have the basic idea but can not understand what I am missing in my application of it. 我试图用同一页上的表单中的值填充合同,我有基本想法,但无法理解我在应用该表单时缺少的内容。
jQuery(function($) {
var input_5 = $('#input_5');
var Child2Name = $('#Child2Name');
var previewinput_5 = $('.Previewinput_5');
var preview2ChildName = $('.PreviewChild2Name');
input_5.keyup(function(e) {
previewChild1Name.text(input_5.val()); });
Child2Name.keyup(function(e) {
preview2ChildName.text(Child2Name.val()); });
});
<li class="form-line" id="id_5">
<label class="form-label-left" id="label_5" for="input_5">
Legal Business Name<span class="form-required">*</span>
</label>
<div id="cid_5" class="form-input">
<input type="text" class=" form-textbox validate[required]"
data-type="input- textbox" id="input_5" name="q5_legalBusiness"
size="20" value="" />
</div>
</li>
<input type="text" name="child2name" id="Child2Name" />
<Label>Child2 Name</label>
Whether it’s what <span class="input_5"></span> <br>
Whether it’s what <span class="PreviewChild2Name"></span> <BR>
The second part works fine, the first is clearly having issues with how the actual form is being displayed 第二部分工作正常,第一部分显然存在与实际表单显示方式有关的问题
You aren't using the right names(variable name and class name) in these lines: 您在这些行中没有使用正确的名称(变量名称和类名称):
var previewinput_5 = $('.Previewinput_5');
Whether it’s what <span class="cid_5"></span>
I assume previewinput_5
should be previewChild1Name
and Previewinput_5
should be cid_5
. 我认为
previewinput_5
应该previewChild1Name
和Previewinput_5
应该cid_5
。 Your fiddle
worked for me because you did the naming in it correctly, which is why I was confused. 您的
fiddle
为我工作是因为您正确地命名了它,这就是为什么我感到困惑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.