我有下列单选按钮:
<input type="radio" name="furtherMission" value="yes" /> yes
<input type="radio" name="furtherMission" value="no" /> no在一种init方法中,我会用“是”或“否”来设置:
$("input[name=furtherMission][value=" + "'" + ${trainee.beu03} + "'" + "]").attr('checked', 'checked');PS:${}是spring表达式。
但我得到了以下错误:
ReferenceError: yes is not defined
$("input[name=furtherMission][value=" + "'" + Ja + "'" + "]").attr('checked', 'c...我的数字也是一样的,在那里也很好。有人知道怎么解决这个问题吗?
发布于 2016-02-11 14:15:14
简而言之,JavaScript认为yes是一个变量名。在jsp中试试这个:
$("input[name=furtherMission][value=['${trainee.beu03}']").attr('checked', 'checked');请记住,trainee.beu03将在服务器中进行评估。它将导致JavaScript中的这个HTML:
$("input[name=furtherMission][value=['yes']").attr('checked', 'checked');发布于 2016-02-11 13:52:49
试着换到这个
$("input[name=furtherMission][value='" + ${trainee.beu03} + "']").attr('checked', 'checked');https://stackoverflow.com/questions/35341130
复制相似问题