OK, I am close...help?

admin

Administrator
Staff member
I submitted a question earlier, but I think there is a way: I have a dynamic form - a user selects the number of diagnostic codes they have and that number of sections appear. This includes a to and from date in drop downs. They also have repeat names ie: 2 diag codes will have 2 fromMonths name/value pairs. When the JSP is submitted, java takes care of parsing.

A change has been requested to a certain functionality: if user changes from date, the to date should change to match the from date.

My thoughts, since it has repeat names, I could capture the form element number (document.forms[0].elements[3]) and then add to the element number to change the value of the appropriate field (the to date).

I think this achievable because in the code below, I am able to capture the sourceIndex. There MUST be some command I could use that would give me the element number.

Oh, and even though the below code captures the number, it doesn't seem to tranlate properly.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>

<script language="javascript" type="text/javascript">
ms_id = 0;
function doit(where,what) {
alert(where);
var f = where + 1;
f = f + 0;
alert(f);
document.forms[0].elements[f].value = what;

}
</script>

</head>

<body>
<form action="" name="fform" id="fform">
<input type="text" name="fieldone" onblur="doit(sourceIndex,this.value);">
<input type="text" name="fieldtwo" onblur="doit(sourceIndex,this.value);">
<br><br>
<input type="text" name="fieldone" onblur="doit(sourceIndex,this.value);">
<input type="text" name="fieldtwo">
<br><br>
<input type="text" name="fieldone" onblur="doit(readyState,this.value);">
<input type="text" name="fieldtwo">


</form>

</body>
</html>
 
Back
Top