View Full Version : Help with Javascript for PDF

01-05-2011, 04:10 PM
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.

Philip M
01-05-2011, 05:58 PM
Here you are:-

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

<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>

<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;


"Often the football piches look barren and parched at this time of the year, mostly due to frost and rain....." - Football Commentator, BBC 2