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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can not display value Calculate () in form field onClick

    I have tried every thing I know but the calculated() function value don't show in the amt form field when you click the Convert button, What is wrong ? Please share your insight Just using note pad.
    _______________________________________________________________



    <HTML>
    <HEAD>

    <title>Wifred Week 4 Indiviual assignment</title>

    <SCRIPT type="text/javascript">
    <!--
    function isNumberKey(evt)
    {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if ((charCode > 31 && charCode < 48 || charCode > 57)){
    alert("Please enter a non-negative number between 0-9 plus two digits trailing a decimal point -> Example: for $50.00 enter -> 5000")
    return false;
    }
    else{




    return true;

    }



    }


    function numberFormat(num)

    {

    num = num.toString().replace(/[,.]/g, '');
    num = num.replace(/\d{2}$/, '.' + num.substr(num.length - 2, 2));
    var regex = new RegExp('(\\d+)(\\d{3})');
    while (regex.test(num))
    {
    num = num.replace(regex, '$1,$2');

    }

    euroamt = parseFloat(num);

    return num;
    }

    </script>


    <script type="text/javascript">

    function calculate(amt)

    {
    usdollar = 1.47;

    var amt = (euroamt*usdollar);

    return valueof(amt);
    }

    </script>

    </HEAD>

    <BODY>

    <div style="text-align:center">
    <h1><b>Fred Flowers</b></h1>
    <h2><b>Web 404</b></h2>
    </div>

    <P>
    <br>
    </p>

    <P>
    <br>
    </p>

    <P>
    <br>
    </p>

    <P>
    <br>
    </p>

    <P>
    <br>
    </p>

    <P>
    <br>
    </p>

    <P>
    <br>
    </p>

    <div style="text-align:center">
    <h3><b>Euro to US dollar Currency Conversion Calculator</b></h3>
    </div>

    <form name="euro" action="Javascript:calculate()" method="post">


    <div class="centered" align="center">



    <table summary="layout of calculation form">



    <tr>

    <th></th>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    </tr>

    <tr>
    <td>
    <p align="center">Please enter the Euro amount you want to be converted here -></td>
    <td>
    <p align="center"><INPUT style="text-align:right" onkeypress="return isNumberKey(event)" id="numberToFormat" oldvalue="" onkeyup="this.value=numberFormat(this.value)" type="text" name="txtChar" value=""></td>

    </tr>


    <tr>

    <th cellpadding="8"></th>

    </tr>

    <tr>
    <td>
    <p align="center">Click on the Convert button here -></td>
    <td>
    <p width="100%" align="center" colspan="3"><input type="button" name="submit" value="Convert" onclick="calculate(amt);"></td>

    </tr>






    <tr>

    <th cellpadding="8"></th>

    </tr>
    <tr>
    <td>
    <p align="center">You will see the Euro amount entered converted to US currency here -></td>
    <td>
    <p align="center"><input style="text-align:right" id="amt" type="text" name="amt" size="20" maxlength="20" value=""></td>

    </tr>




    </table>

    </div>

    </form>
    </BODY>
    </HTML>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Why are you using action and not onsubmit?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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