作为一个新手,我正在努力了解如何混合'在jsp中运行的同一函数中的HTML和Javascript,以及是否允许这样做。如果我尝试混合代码'该功能无法运行。
我有一个SQL查询测试,它返回一个单元格是否有照片'指示符,如果是的话,我想启动网络摄像头代码,即
<c:if test="${row.ftypeid==3}">
<script>
Camera();
</script>
然后启动网络摄像头的功能就像 -
function Camera{
<tr>
<td width="200px"><b>Webcam Photo</b></td>
<td>
<input type="file" name="photo"/>
<br>
<script language="JavaScript">
webcam.set_api_url( 'upload.jsp' );
webcam.set_quality( 90 ); // JPEG quality (1 - 100)
webcam.set_shutter_sound( true ); // play shutter click sound
document.write( webcam.get_html(320, 240) );
</script>
<br>
<input type=button value="Configure..." onClick="webcam.configure()">
<input type=button value="Take Snapshot" onClick="take_snapshot()">
<br>
jsp中的常规过程似乎只是javascript,完全包含在标签中。是否可以混合&#39;这样的代码?
如果我尝试在&#39; if test&#39;之后立即添加网络摄像头代码(这也显示任何现有存储的照片)然后这似乎“腐败”&#39;存储的照片然后产生错误(如果保存则显示2个浏览按钮而不是1)。
</c:if>
<c:if test="${row.ftypeid==3}">
<input type="file" name="f${row.sequence}">
<tr>
<td width="200px"><b>Webcam Photo</b></td>
<td>
<input type="file" name="photo"/>
<br>
<script language="JavaScript">
webcam.set_api_url( 'upload.jsp' );
赞赏的想法。
此致 活性
答案 0 :(得分:0)
不,不允许 - 我认为你的意思是
<c:if test="${row.ftypeid==3}">
<tr>
<td width="200px"><b>Webcam Photo</b></td>
<td>
<input type="file" name="photo"/>
<br>
<script language="JavaScript">
webcam.set_api_url( 'upload.jsp' );
webcam.set_quality( 90 ); // JPEG quality (1 - 100)
webcam.set_shutter_sound( true ); // play shutter click sound
document.write( webcam.get_html(320, 240) );
</script>
<br>
<input type=button value="Configure..." onClick="webcam.configure()">
<input type=button value="Take Snapshot" onClick="take_snapshot()">
<br>
</c:if>