Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Add


Message #1 by "Nato Castro" <natocastro@h...> on Thu, 16 Aug 2001 22:45:18
--- Nato Castro <natocastro@h...> wrote:
> Hi to all,
> I'm working in a form where the user will enter
> numbers e.g., text1=4 and 
> text2=4 and text3=total which will be 8. My question
> is where do I need to 
> put it and how do I call it?
> I already create a function, but for some reason it
> doesn't work..here is 
> the code..
> 
> function DrvAdd()
> {
>    A = parseInt(document.form.INTERLT100.value);
>    B = parseInt(document.form.INTERLT100.value);
>    C = (A+B);
>    document.form.TOT_DRS.value = C
> }
> 
> Could you please help me..
> Thanks in advanced
> 
> Nato..
> ---

  Note this (immediately after the body tag):

<SCRIPT LANGUAGE="JavaScript">
function DrvAdd()
{
>    A = parseInt(document.form.INTERLT100.value);
>    B 
parseInt(document.form.INTERLT100.value);//Are you
sure?
>    C = (A+B);
>    document.form.TOT_DRS.value = C
/* You can write simply:
  TOT_DRS.value = parseInt(INTERLT100.value) +
parseInt(INTERLT100.value);
  //(Of course, supposing that you have the
appropriate text boxes)
*/  
}
</SCRIPT>
  You may call the function on losing focus either on
text1, either on text2
<INPUT TYPE="text" name="INTERLT100"
onblur="DrvAdd()">

  Good luck!


  Return to Index