Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选中JSP scriptlet变量中的单选按钮_Javascript_Jquery_Jsp_Radio Button_Scriptlet - Fatal编程技术网

Javascript 选中JSP scriptlet变量中的单选按钮

Javascript 选中JSP scriptlet变量中的单选按钮,javascript,jquery,jsp,radio-button,scriptlet,Javascript,Jquery,Jsp,Radio Button,Scriptlet,这将是一个愚蠢的问题,但我需要问它。 附言:这是一个古老的做法,但我需要这样做。 在scriptlet中,我有一个变量status <% String status=bean.getStatus(); //Status value is coming from database which is either "1" or "0"(String type) %> 在表格中我有单选按钮 <tr> <td> Status :</td&g

这将是一个愚蠢的问题,但我需要问它。 附言:这是一个古老的做法,但我需要这样做。 在scriptlet中,我有一个变量
status

 <%
   String status=bean.getStatus();
   //Status value is coming from database which is either "1" or "0"(String type)
 %>

在表格中我有单选按钮

<tr>
<td> Status :</td>
<td>Active
            <input type="radio" name="status" checked="checked" id="statusAct" value="1" />
    Inactive
           <input type="radio" name="status" id="statusInac" value="0"/>
</tr>

地位:
活跃的
不活跃的
如果
status==1
我希望选择带有
id=“statusAct”
的单选按钮,如果
status==0
则选择带有
id=“statusInac”
的单选按钮


我可以使用javascript或Jquery,但我不知道如何将Java变量放入javascript函数中。

或者使用Scriptlet执行条件逻辑,然后在需要的地方写入checked=“checked”。在scriptlets中,您可以完成。println写入页面(输出流)。 您还可以将jstl用于条件标记c:如果

<input type="radio" name="status" <% ${bean.getStatus() == '1' ? 'checked="checked"' : '' } %> id="statusAct" value="1" />


可能
var status=“”
然后
如果(status='1'){$('#id').prop('checked',true);}
您好,我试图从URL将其用作输入参数,但在标记“$”上得到错误
语法错误,此标记后应为AssignmentOperator
请参阅我的语法:
<input type="radio" name="status" <% ${bean.getStatus() == '0' ? 'checked="checked"' : '' } %> id="statusInac" value="1" />