Click to See Complete Forum and Search --> : OK, I am close...help?


mawood
02-14-2003, 05:16 PM
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>

mawood
02-14-2003, 06:52 PM
Your wording seems like you think I doubted you. I meant no disrespect, I really appreciate your help. My attempt here was not to belittle you, but to continue checking. There might have been an answer from someone who may know a trick. If I implied anything negative, I am truly sorry.

mawood
02-14-2003, 09:30 PM
How?

mawood
02-15-2003, 10:06 AM
Now THAT is exactly what I am looking for. Very impressive!!! Dave, I loooooove you, man!! I so extremely, earnestly, sincerly, absolutely thank you. I really mean....THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU!!!

Did I forget to express my thanks?

mawood
02-15-2003, 10:39 AM
Now I feel thankful AND guilty. :)

clint_9090
02-26-2003, 05:26 PM
I need to identify a form's id from one of it's elements. Does anyone know how to do this.

Here's an example of what I'm trying to do:
<script>
function getFormID(inFormElement){
sourceForm = inFormElement.parent (this doesn't work, but is there a way to do this);
alert("you clicked on "+sourceForm.id);
}
</script>

<form id=Form1>
<input type=button onclick="getFormID(this)">
</form>

<form id=Form2>
<input type=button onclick="getFormID(this)">
</form>

clint_9090
02-26-2003, 07:47 PM
Thanks Dave!
Wow, that was quick!!!