Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Thanked 0 Times in 0 Posts

    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 10:36 PM. Reason: Fixed!

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,703 Times in 2,679 Posts
    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


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts