aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to pass data of text field to javascript function? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to pass data of text field to javascript function?" Watch "How to pass data of text field to javascript function?" New topic
Author

How to pass data of text field to javascript function?

Dipti Lokhande
Greenhorn

Joined: May 05, 2007
Posts: 9
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

Joined: Jan 10, 2002
Posts: 61433
    
  67

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 .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Soundar Sweet
Ranch Hand

Joined: Dec 17, 2004
Posts: 31
Try


Soundar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to pass data of text field to javascript function?