Using Javascript to Validate Dynamically created HTML Forms
The code below creates a form based on the users assigned to a course, therefore it is dynamic and to make each name for the Text Box that contains there score I have to append the user's id. How do I maneuver through the text boxes with JS if I don't know the names o fhte elements???
Code:
if isarray(arrStudents) then
fltScore = ""
for i = 0 to ubound(arrStudents,2)
IF Application("RDBMS") = "ORACLE" THEN
rs.Open "SELECT student_score/possible_score*100 FROM assessment_report WHERE student_id = " & arrStudents(0,i) & " AND container_id = " & request("session") & " AND testinstance = 1"
ELSE
rs.Open "SELECT CAST(student_score AS DECIMAL) / CAST(possible_score AS DECIMAL) *100 FROM assessment_report WHERE student_id = " & arrStudents(0,i) & " AND container_id = " & request("session") & " AND testinstance = 1"
END IF
if rs.EOF then
fltScore = 0
else
fltScore = rs(0)
end if
rs.close
Response.Write "<tr><td>" & arrStudents(1,i) & " " & arrStudents(2,i) & "</td>"
%>
<td><input name="txtScore<%=arrStudents(0,i)%>" value="<%=fltScore%>" size="4" onchange="javascript:if (isNaN(parseFloat(this.value))==true){alert('<%=strNOTANUMBER%>');this.value='';this.focus();}"></td><td></td></tr>
<%
next
else
Response.Write "<td colspan=2>" & strNOSTUDENTS & "</td></tr>"
end if