Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-05-2011, 03:10 PM   PM User | #1
alwclimbs
New to the CF scene

 
Join Date: Jan 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
alwclimbs is an unknown quantity at this point
Help with Javascript for PDF

I need a JavaScript code for a PDF that populates a multiplication problem between two List Boxes

I'm creating a PDF membership contract and I have two list boxes; one that generates a price and one that is a duration period (3 month, 6 Months, etc..) I need the two list boxes to communication with each other to multiply the price with the duration and that number to appear in a text box.

Example: List box 1 says student membership is $25. List Box 2 says 3 Months. When I click the options, the Text Box will produce a number, in this case $75.00.

Last edited by alwclimbs; 01-05-2011 at 09:36 PM.. Reason: Fixed!
alwclimbs is offline   Reply With Quote
Old 01-05-2011, 04:58 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Here you are:-

Code:
<select id = "list1" onchange = "calc()">
<option value = 0>Select a membership type</option>
<option value = 25>Student</option>
<option value = 50>Full</option>
</select>

<select id = "list2" onchange = "calc()">
<option value = 0>Select a period</option>
<option value = 3>3 months</option>
<option value = 6>6 months</option>
<option value = 12>12 months</option>
</select>

<br>
<input type = "text" id = "result">

<script type = "text/javascript">
function calc() {
document.getElementById("result").value = "";
var a = document.getElementById("list1").value;
var b = document.getElementById("list2").value;
if (a !=0 && b !=0) {
var c = a * b;
document.getElementById("result").value = "$" + c;
}
}

</script>
"Often the football piches look barren and parched at this time of the year, mostly due to frost and rain....." - Football Commentator, BBC 2
Philip M is offline   Reply With Quote
Reply

Bookmarks

Tags
contract, javascript, list box, multiplication, pdf

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 AM.


Advertisement
Log in to turn off these ads.