passing value from one field to another

M

ms.jennylim

hi,
i am new to jsp programming, and is stuck with the following situation.
i got an employee form with fields like emp no., username, etc. the
value entered in emp no. is supposed to be reflected in username upon
going to the next field. also, i am trying to grey out the field to
certain role of user. any suggestion abt the syntax?

my current syntax is :-
<form name="insertForm" method="POST" action="updateStaffDetails.jsp"
onSubmit="return validateEntries(document.insertForm)">
<table border="0" cellpadding="2" cellspacing="0" width="710">
<tr>
<td width="147" align="left">Staff ID *</td>
<td width="551" align="left"><!--webbot bot="Validation"
S-Display-Name="EmployeeID" S-Data-Type="Integer"
S-Number-Separators=","
B-Value-Required="TRUE" I-Maximum-Length="8" --><input
type="text" name="empNo" size="10" maxlength="8">
</td>
</tr>
<tr>
<td width="147" align="left">Staff Name *</td>
<td align="left" width="551"><!--webbot bot="Validation"
B-Value-Required="TRUE" I-Maximum-Length="30" --><input
type="text" name="empName" size="30" maxlength="30" > </td>
</tr>
<tr>
<td width="147" align="left">Company *</td>
<td width="551" align="left">
<select name="coCode" size="1"
onChange="addDivisionOptions(document.insertForm, ' ');
addDepartmentOptions(document.insertForm, ' ')">
<%
i = 0;
while (coCodeList != null) {
if (coCodeList.equals(coCode)) {
%>
<option value=<%= coCodeList %> selected><%= coCodeList
%>&nbsp;&nbsp;<%= coNameList[i++] %>
<%
}
else {
%>
<option value=<%= coCodeList %>><%= coCodeList
%>&nbsp;&nbsp;<%= coNameList[i++] %>
<%
}
}
%>
</select>
</td>
</tr>
<tr>
<td width="147" align="left">Division *</td>
<td width="551" align="left">
<select name="divCode" size="1"
onChange="addDepartmentOptions(document.insertForm, ' ')"></select>
</td>
<tr>
<td width="147" align="left">Department *</td>
<td width="551" align="left">
<select name="deptCode" size="1"></select>
</td>
<tr>
<td width="147" align="left">Role *</td>
<td width="551" align="left">
<select name="role" size="1">
<option value="STAFF" selected>Staff
</select>
</td>
</tr>
<tr>
<td width="147" align="left">Executive Flag *</td>
<td width="551" align="left">
<select name="executiveFlag" size="1">
<option value="Y" selected>Yes
<option value="N">No
</select>
</td>
</tr>
<tr>
<td width="147" align="left">User Name </td>
<td width="551" align="left">

<!--webbot bot="Validation" B-Value-Required="TRUE"
I-Minimum-Length="5"
I-Maximum-Length="10" -->
<input type="text" name="userName" size="10" maxlength="10">
</td>
</tr>
<tr>
<td width="147" align="left">InActive Date</td>
<td width="551" align="left"><!--webbot bot="Validation"
B-Value-Required="TRUE" I-Maximum-Length="10" --><input
type="text" name="inactiveDate" size="10" maxlength="10">
<a href="javascript:showCalendar('document.insertForm.inactiveDate',
document.insertForm.inactiveDate.value, true);">
<img src="images/bt_calendar.gif" heigh=21 border=0 align=top></a>
</td>
</tr>
</table>
<p><input type="submit" value="Save" name="Save">&nbsp;&nbsp;&nbsp;
<input type="hidden" value="I" name="operationFlag">
<input type="button" value="Refresh" onclick="location.reload()">
</form>

i tried inserting value="<%= empNo %>" at the username but
unsuccessful. pls help.

thanks.
 
J

John C. Bollinger

hi,
i am new to jsp programming, and is stuck with the following situation.
i got an employee form with fields like emp no., username, etc. the
value entered in emp no. is supposed to be reflected in username upon
going to the next field. also, i am trying to grey out the field to
certain role of user. any suggestion abt the syntax?

With JSP you must always keep in mind where and when processing occurs:
on the server, after receiving an HTTP request and in the process of
creating and sending the response. In particular, this means that JSP
cannot respond directly to client-side events, such as the user moving
from one field to another. You need client-side code for that,
typically JavaScript. JSP certainly can output HTML that contains
suitable JavaScript code, as your example (elided) shows.
i tried inserting value="<%= empNo %>" at the username but
unsuccessful. pls help.

To reinforce the point, no scriptlet can do the job you want because the
value needs to be set in response to client action. [Moreover, if you
were doing this on the server side you would want <% empNo %> (with no
"=").]


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top