I have to use dynamic ids in my form, based on jsp variables in a scriptlet. How can I select the correct element using jQuery’s id selector without getting errors?
Here’s my code:
<form name="intakeOnly" id="intakeOnly_<%=complaint%>" method="post" action="../Intake.do">
<table class="normal">
<tr>
<td><b>Clinician Signature: </b> <span id="cSigI_<%=complaint%>"><%=clinicianSig%>,<%=signedDate%></span></td>
</tr>
<tr>
<td><input type="button" id="submitSig_<%=complaint%>" name="submitSig" value="Sign and Save" onClick="intakeSubmit();"></td>
</tr>
</table>
</form>
Javascript:
function intakeSubmit() {
var complaint = <%=complaint%>;
var fname = new String("<%=userFirstName%>");
var lname = new String("<%=userLastName%>");
var date = new String("<%=DateUtils.getDate()%>");
jQuery("#cSigI_"+complaint).append("<br>"+fname+" "+lname + ","+ date);
}
This line:
should be
The lines following that should be changed to match that syntax,
new String(str)isn’t needed.