I am new to web development and I am trying to get the Patient Id (patid) from the selected name from the list. Can this be done like this? out.println("<select name=\"patientName\" onChange=\"patid=resident.get(this.selectedIndex).getPatId();\" >");
If not, can you make a suggestion to how I would do this.

<% try {

ArrayList<Patient> residents = service.getPatientList(loginInfo.getUserid());
String selectedPatient = request.getParameter("selectedPatient");
int index = 0;
//<select onchange="location = this.options[this.selectedIndex].value;">
out.println("<select name=\"patientName\" onChange=\"patid=resident.get(this.selectedIndex).getPatId();\" >");
for (int ii = 0; ii < residents.size(); ++ii) {
if (residents.get(ii).getPatId() == currentPatient.getPatId())
out.println("<option name=\"selectedPatient\" value=\""
+ residents.get(ii).getName()
+ "\"selected=\"selected\">"
+ residents.get(ii).getName() + "</option>");
else
out.println("<option name=\"selectedPatient\" value=\""
+ residents.get(ii).getName() + "\">"
+ residents.get(ii).getName() + "</option>");
}
out.println("</select>");
residents.clear();
} catch (Exception e) {
out.println(e.getMessage());
}
%>
<input type="hidden" class="input" name="patid" id="patid" value=patid/>
<input type="submit" name="Search" class="button" value="Switch Resident" />
<br> <input type="submit" name="OrderEntry" class="button" value="Order Entry" />