Click to See Complete Forum and Search --> : From child to parent: Alert message


rjusa
11-05-2003, 05:55 PM
I have a form that opens a child window, inputs are made,the window is closed and the inputs are put in the parent...I've writtena routine that takes the element "percent1" from the parent and adds to it the element "perecnt2" from the child...if the total is >100, an alert pops up informing of the violation. The way I have it set up, you must be "in focus" in the parent "percent1" field and when you leave, (i.e., lose focus) the routine is run. How could I do this so that the routine is run automatically when you leave the child? My code in the parent is as follows:

<script language="JavaScript"><!--
function sum(objRef) {
var result = 0;
result += document.forms[0].CndnFBpc.value - 0;
result += document.forms[0].CndnSBpc.value - 0;
result += document.forms[0].CndnCFBpc.value - 0;
result += document.forms[0].CndnCSBpc.value - 0;
if (result > 100)
alert("Your allocation exceeds 100%, please check your distribution");
}//--></script>

onBlur="sum(this)"

Thanks,
Ron

Khalid Ali
11-05-2003, 06:31 PM
use onkeyup in child window textfields,this way it will be validated for every entry