...

View Full Version : Can not display value Calculate () in form field onClick



FREDf
12-25-2007, 06:39 PM
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>

A1ien51
12-26-2007, 06:04 AM
Why are you using action and not onsubmit?

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum