?
Solved

Adding two text fields together to a third total text fields

Posted on 2008-10-28
5
Medium Priority
?
1,172 Views
Last Modified: 2012-05-05
I have a form that I want to pass an "amount" variable to paypal.    My user has two distinct sets of radio buttons that feed two text boxes and I would like to add those two text boxes on the fly to a third text box showing the total before the user passes that value to paypal builtin "amount" variable.  I am using paypal toolkit and have not found a way to manipulate these variable after the form is posted to my processing page.  I don't want to use javascript but have not found another method in my searches.  Here is my code...can you help me to get this to work...Secondarily does anyone know where I can find some documentation for the php toolkit..I am solely dependent on their read me file..this is not my primary question..thx for the help
<html>
 
 
<head>
   
     <script language="JavaScript" type="text/JavaScript">
 
     function add() {
     var total= ((document.test.abc.value*1) + (document.test.abd.value*1));
     document.test.total.value=total;
     }
     </script>
</head>
 
 
 
<body>
<center>
<form name="test">
<input type=radio name=R1 value=40.00 onclick="document.test.abc.value=
 
this.value">40.00<br>
<input type=radio name=R1 value=50.00  onclick="document.test.abc.value=
 
this.value">50.00
 
<br><br>
<br>
<input type=radio name=R2 value=5.00 onclick="document.test.abd.value=
 
this.value">5.00<br>
 
<input type=radio name=R2 value=10.00 onclick="document.test.abd.value=
 
this.value">10.00<br>
 
<input type=radio name=R2 value=15.00 onclick="document.test.abd.value=
 
this.value">15.00<br>
<input type=text name=abc onchange="add();" value ="" >
<input type=text name=abd onchange="add();" value ="">
<input type=text size="5"  name=total  >
<input type="reset" name="reset">
</form>
</center>
</body>
 
</html>

Open in new window

0
Comment
Question by:greta13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22824342
var total= ( parseInt(document.test.abc.value*1) + parseInt(document.test.abd.value*1));
0
 

Author Comment

by:greta13
ID: 22824489
This has to be put in the head as part of a function doesn't it?
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22825059
just call add() after you click the radio buttons:
<html>
 
 
<head>
   
     <script language="JavaScript" type="text/JavaScript">
 
     function add() {
     var total= ((document.test.abc.value*1) + (document.test.abd.value*1));
     document.test.total.value=total;
     }
     </script>
</head>
 
 
 
<body>
<center>
<form name="test">
<input type=radio name=R1 value=40.00 onclick="document.test.abc.value=this.value; add();">40.00<br>
<input type=radio name=R1 value=50.00  onclick="document.test.abc.value=this.value; add();">50.00
 
<br><br>
<br>
<input type=radio name=R2 value=5.00 onclick="document.test.abd.value=this.value; add();">5.00<br>
 
<input type=radio name=R2 value=10.00 onclick="document.test.abd.value=this.value; add();">10.00<br>
 
<input type=radio name=R2 value=15.00 onclick="document.test.abd.value=this.value; add();">15.00<br>
<input type=text name=abc onchange="add();" value ="" >
<input type=text name=abd onchange="add();" value ="">
<input type=text size="5"  name=total  value="">
<input type="reset" name="reset">
</form>
</center>
</body>
 
</html>

Open in new window

0
 

Author Closing Comment

by:greta13
ID: 31510852
Thanks
0
 
LVL 82

Expert Comment

by:hielo
ID: 22825991
glad to help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question