Currency converter script in a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • printline
    New Member
    • Jul 2006
    • 89

    Currency converter script in a form

    Hello all

    I have a form where a user can type in some information about a product he wants to buy and then get a price on the product.

    The price he gets depends on how many working days he wants the product to be produced on, so there can be multiple prices.

    Can anyone provide me with a script that makes it possible for the user to see the price in another currency......? It could be either by clicking an icon or a drop down field that makes it able for him to choose another currency for this price......
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    http://www.google.co.uk/search?hl=en...ency+converter.

    Have you thought about the changing currency rates?

    Comment

    • printline
      New Member
      • Jul 2006
      • 89

      #3
      Found one i could use.

      Thanks a lot

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        No problem, you're welcome.

        Comment

        • printline
          New Member
          • Jul 2006
          • 89

          #5
          Originally posted by acoder
          No problem, you're welcome.
          Could you perhaps help me modify the script i found a bit.....?

          The script i found requires that you type in an amount in a text field and then choose from a select list which currency to convert the amount into.

          What i need it to do is to have a predefined value in the text field.

          Here is my code:


          Code:
          <script language="JavaScript" type="text/javascript">
          
          var f36_CAry=new Array();
          f36_CAry[0]=['DKK',7.5856];
          f36_CAry[1]=['SEK',9.3131];
          f36_CAry[2]=['£POUND',0.7527];
          f36_CAry[3]=['$US',1.4736];
          
          
          </script>
          
          <script language="JavaScript" type="text/javascript">
          
          function f36_InitCurrency(f36_ip,f36_sel,f36_ary){
           f36_CIP=document.getElementById(f36_ip);
           f36_Sel=document.getElementById(f36_sel);
           f36_Sel.options.length=0;
           f36_Sel.options[0]=new Option(f36_CIP.value,1,true,true);
           for (f36_0=0;f36_0<f36_ary.length;f36_0++){
            f36_Sel.options[f36_0+1]=new Option(f36_ary[f36_0][0],f36_ary[f36_0][1],true,true);
           }
           f36_Sel.selectedIndex=0;
           f36_Sel.ip=f36_CIP;
           f36_Sel.base=f36_CIP.value;
           f36_Sel.onchange=function(){ f36_Calculate(this); }
           f36_CIP.sel=f36_Sel;
           f36_CIP.onfocus=function(){ f36_Focus(this); }
           f36_CIP.onblur=function(){ this.v=this.value; }
           f36_CIP.onkeyup=function(){ this.value=this.value.replace(/[^0123456789.]/g,''); }
          
          }
          
          function f36_Focus(obj){
           obj.value='';
           obj.sel.selectedIndex=0;
          }
          
          function f36_Calculate(f36_obj){
           if (f36_obj.ip.value.length<1||f36_obj.ip.value==f36_obj.base){ return; }
           f36_v=Math.ceil((Number(f36_obj.ip.v)*100*f36_obj.options[f36_obj.selectedIndex].value));
           f36_obj.ip.value=(f36_v/100).toFixed(2);
          }
          
          
          </script>
          
          <select  class="TxtArea" id="CurrencySel" style="width:100px;" ></select>
          <input id="CurrencyIP" type="text" size="10" value="Euro" />

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by printline
            What i need it to do is to have a predefined value in the text field.
            Just set the value attribute in the HTML.

            Comment

            Working...