Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass data of text field to javascript function?

 
Dipti Lokhande
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to pass data of one field on the event of other field to javascript function?

The code is given below :

function calculate(data1,data2)
{
var total = data1 * data2;
document.form.txtTotal.value = total;
}
:
:
:
<%
int i = 0;
while (i < 3)
{
%>
No1 : < input type = "text" name = "txtNo1"> <br>
No2 : < input type = "text" name = "txtNo1"> <br>
Total : < input type = "text" name = "txtTotal" onFocus = "calculate(data of txtNo1, data of txtNo2)"> <br>
<%
}
%>

I want to send value of txtNo1 & txtNo2 on onFocus event of txtTotal.
In the fucntion calculate(), I can not access their values of txtNo1 and txtNo2 directly by using docuement.form.......
How to achieve this?
[ May 09, 2008: Message edited by: Dipti Lokhande ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Soundar Sweet
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic