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

    help needed for simple code in Adobe forms

    Hi...

    I am not sure if this is the correct forum, so please bear with me.

    I am trying to design a Purchase Order form in Adobe Life Cycle 8. What I basically want is a drop-down box with around 8 fixed options, and the user selects one. As a result of that selection, another text box gets populated with a pre-determined text string. In this case, the drop-box contains a list of products, and when a client selects a product, its product code should automatically appear in another text box. This is to minimize the chance of error on the client's part in entering the product code.

    Now I can't figure out how to "get" the value (assigned or actual) of the item selected in the drop-box and how exactly to relate the drop-box and the text box.

    Can someone help?

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    Someone else posted this earlier this week here. I liked it so I saved a copy. You should be able to adapt this to your needs.
    Code:
    <html>
    <head>
    <title>DD Calculations</title>
    <script type="text/javascript">
    function getSBox(IDS) {
      var obj = document.getElementById(IDS);
      return obj.value;
    }
    function calc() {
      var sum = 0;
      var temp = '';
          temp = getSBox('Machine');
      var Machine = Number(temp);  
      if (isNaN(Machine) || (Machine == 0)) { sum = 0; } else { sum = Machine; }
          temp = getSBox('Term');
      var Term = Number(temp);  
      if (isNaN(Term) || (Term == 0)) { sum = 0; } else { sum += Term; }
      if (sum == 0) { 
    	temp = 0;
      } else {  
        temp = Machine / Term * 3;
      }
      document.getElementById('deposit').value = temp.toFixed(2);
      return;
    }
    </script>
    </head>
    <body>
    <select id="Machine" name="machine" onchange="calc()">
     <option value="">Choose machine</option>
     <option value="4000">2005 - Almida XAS47 (660 Hours) £4000</option>
     <option value="5000">Something else £5000</option>
    
     <option value="6000">Something completely different  £6000</option>
    </select>
    <select id="Term" name="term" onchange="calc()">
     <option value="">Choose term</option>
     <option value="12">1 years</option>
     <option value="18">1.5 years</option>
     <option value="24">2 years (&pound;46.85)</option>
    
     <option value="60">5 years</option>
    </select>
    <input id="deposit" name="deposit" readonly/>
    </body>
    </html>

  • Users who have thanked TinyScript for this post:

    nophster (04-13-2009)

  • #3
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    How is this a XML question? Do you have source code for us to work with?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #4
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by TinyScript View Post
    Someone else posted this earlier this week here. I liked it so I saved a copy. You should be able to adapt this to your needs.
    Code:
    <html>
    <head>
    <title>DD Calculations</title>
    <script type="text/javascript">
    function getSBox(IDS) {
      var obj = document.getElementById(IDS);
      return obj.value;
    }
    function calc() {
      var sum = 0;
      var temp = '';
          temp = getSBox('Machine');
      var Machine = Number(temp);  
      if (isNaN(Machine) || (Machine == 0)) { sum = 0; } else { sum = Machine; }
          temp = getSBox('Term');
      var Term = Number(temp);  
      if (isNaN(Term) || (Term == 0)) { sum = 0; } else { sum += Term; }
      if (sum == 0) { 
    	temp = 0;
      } else {  
        temp = Machine / Term * 3;
      }
      document.getElementById('deposit').value = temp.toFixed(2);
      return;
    }
    </script>
    </head>
    <body>
    <select id="Machine" name="machine" onchange="calc()">
     <option value="">Choose machine</option>
     <option value="4000">2005 - Almida XAS47 (660 Hours) £4000</option>
     <option value="5000">Something else £5000</option>
    
     <option value="6000">Something completely different  £6000</option>
    </select>
    <select id="Term" name="term" onchange="calc()">
     <option value="">Choose term</option>
     <option value="12">1 years</option>
     <option value="18">1.5 years</option>
     <option value="24">2 years (&pound;46.85)</option>
    
     <option value="60">5 years</option>
    </select>
    <input id="deposit" name="deposit" readonly/>
    </body>
    </html>
    thanks for sharing this coding..can this code use in wordpress base?

  • #5
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Alex Vincent View Post
    How is this a XML question? Do you have source code for us to work with?
    Can you suggest an appropriate forum for posting questions related to Adobe forms? The language there is either Java or FormCalc. My question was related to FormCalc and I do not see a forum for that here.

    Can someone tell me how to get the value of the current selected option from a drop-down list in FormCalc? If there is a drop-down list called Products1, and the options are Prod1, Prod2 and Prod3.....I would like to declare a variable and assign it a value of '1' if Prod1 is selected, '2' if Prod2 is selected and so on. This way, I want to use the 'if' statement to check which value is selected and to populate another field depending on that selection.

    How do I do that?

  • #6
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ok I got the solution and here it is, in case anyone is interested. To repeat: this is being used where a drop-down list has various options, and upon the selection of one option another field gets populated with the data corresponding to the selection. In this case, product Car gets selected and the field titled 'UnitPrice' gets populated with the associated price.

    Code:
     
    (JavaScript, client)
    
    switch (xfa.event.newText)
    {
        case "Car":
            UnitPrice.rawValue = 16.8;
            break;
    
        case "Truck":
            UnitPrice.rawValue = 9.50;
            break;
    
        default:
            // unknown item
            UnitPrice.rawValue = 0;
            break;
    }
    I would understand if this topic gets moved to the JS board. I was initially looking for a solution in the FormCalc syntax.


  •  

    Posting Permissions

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