mardi 29 novembre 2016

Javascript if else condition for fields depending on values selected

I have a problem with a condition statement with 4 fields involved

  1. Issuing country select field [ Select field ]
  2. Currency of the amount to be paid [ Select Field ]
  3. Conversion of the amount entered [ Input Field ]

    //if "AUS" is selected auto-select AUD as currency and run the second function to the amt_input field
    
    
    
    <select name="issuing_country" id="issuing_country">
        <option value=""> -- Please Select --</option>
        <option id="ARG" value="ARG">Argentina</option>
        <option id="USA" value="ARM">Armenia</option>
        <option id="ABW" value="ABW">Aruba</option>
        <option id="AUS" value="AUS">Australia</option>
     <select> 
    
    
    
    //Select a currency:
    
    <tr class="shade">
       <td align="left">Currency: &nbsp;</td>
       <td>
          <select name="vpc_Currency">
             <option value="USD">USD</option>
             <option value ="AUD" selected>AUD</option>
          </select>
       </td>
    </tr>
    
    

    //where to enter the amount//

     <input type="text" name="amt" value="">
    
    

    //field that will reflect the computation//

      <input id="Total_Amount" name="vpc_Amount" value=""/>
    
    
    //Javascript//
    
    <script type="text/javascript">
    
       function ().call(){
    
             var amt;
                function.do{
    
    

    //if USD is selected to be converted to AUD in the amt field//

                    if (vpc_Currency = "USD")&&(AUS)
                    var amount = (usd * 1.36) * 1.023;
                    return amount;
    
    

    //if AUD currency and issuing bank is AUS//

             else if (vpc_Currency = "AUD")&&(loc='AUS')
                    var amount = [(aud * 1.023) * 1.1]
                    return amount; 
    
    

    //if different country and bank automatic select USD as currency//

                    else (aud * 1.023);
                    return amount;
                }
         }
    
    

Aucun commentaire:

Enregistrer un commentaire