gpt4 book ai didi

javascript - 新表单字段中的 "unrecognized expression"

转载 作者:行者123 更新时间:2023-11-28 11:24:35 27 4
gpt4 key购买 nike

我遇到了一种情况,我有一个用 javascript 编写的表单,它为人们创建个人资料,详细说明了他们的姓名简历等。无论如何,我尝试向此表单添加一些新字段,但我添加的每个新字段都是当我尝试编辑个人资料信息时,抛出“无法识别的表达式”错误。

从“fname”到“owner”的所有字段都很好,但低于该值的任何字段都会引发错误。与上面的解释一致,“owner”下面的所有字段都是我最近添加的新字段。

    createForm: function(n) {
item = $("<table> \
<tr><th>Name</th><td class='twoinput'><input name='pfname' placeholder='Jane'/><input name='plname' placeholder='Smith'/></tr> \
<tr><th>Title</th><td><input name='ptitle' placeholder='Chief Executive Officer'/></tr> \
<tr><th>Short Bio</th><td><textarea name='pbio'/></textarea></td></tr> \
<tr><th>Photo</th><td><input id='photo_upload' name='photo'/> <input type='button' id='photo_button' value='Open Media Library'/></tr> \
<tr><td colspan='2'>(Optional) Upload a photo of <acronym title='Replace this with their first name?'>this person</acronym>. The bigger the better&mdash;don't worry, we'll scale this down for you.</td></tr> \
</table>\
<br/>\
<table>\
<tr><th>Education</th><td><textarea name='pedu'/></textarea></td></tr> \
<tr><th>Relevant Skills</th><td><textarea name='pskills'/></textarea></td></tr> \
<tr><th>Professional Experience</th><td><textarea name='pprof'/></textarea></td></tr> \
<tr><th>Awards & Recognition</th><td><textarea name='pawards'/></textarea></td></tr> \
<tr><th>Community Involvement</th><td><textarea name='pcommunity'/></textarea></td></tr> \
<tr><th>Years with the Company</th><td><input type='text' size='2' maxlength='2' name='pyears'/>years</td></tr>\
<tr><th>Compensation Details</th><td><textarea name='pcompensation'/></textarea></td></tr> \
</table>\
<br/>\
<table>\
<tr><td id='ownershipquestion' colspan='2'>Does this person have an ownership stake?</td><td id='ownershipbox'><input type='checkbox' id='part_owner' name='owner' value='1'/>Yes</td></tr>\
<tr><td id='ownershipperquestion' colspan='2'>What percentage does this person hold?</td><td id='ownershipperanswer'><input type='text' size='3' maxlength='3' id='ownership_percentage' name='ownership_percentage'/>%</td></tr>\
</table>");
if(n < upsmart.people.people.length) {
p = upsmart.people.people[n];
item.find("input[name=pfname]").attr("value",p.fname);
item.find("input[name=plname]").attr("value",p.lname);
item.find("input[name=ptitle]").attr("value",p.title);
item.find("textarea[name=pbio]").attr("value",p.bio);
item.find("input[name=photo]").attr("value",p.photo);
item.find("input[name=owner]").attr("value",p.owner);
item.find("input[name=ownership_percentage]").attr("value",p.ownership_percentage);
item.find("input[name=pedu").attr("value",p.edu);
item.find("input[name=pskills").attr("value",p.skills);
item.find("input[name=pprof").attr("value",p.prof);
item.find("input[name=pawards").attr("value",p.awards);
item.find("input[name=pcommunity").attr("value",p.community);
item.find("input[name=pyears").attr("value",p.years);
item.find("input[name=pcompensation").attr("value",p.compensation);
}
return item;
},

错误消息的确切措辞示例如下:

Error: Syntax error, unrecognized expression: input[name=pedu

所有相关的 javascript 函数都可以 viewed here.

提前致谢。

注意:这是帖子中描述的问题的演变:Problems saving data in added fields to a javascript form

最佳答案

您缺少几个右括号。

item.find("input[name=pedu").attr("value",p.edu);

应该是

item.find("input[name=pedu]").attr("value",p.edu);

关于javascript - 新表单字段中的 "unrecognized expression",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18541190/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com