要完成此效果需要两个步骤
第一步:把如下代码加入到<head>区域中
<SCRIPT LANGUAGE="JavaScript"> <!-- Begin function s(num, val) { amount = num * 1; // amount is the num or NaN sum = (!num ? 0 : num) * val; // the sum for that bill or coin
if (isNaN(amount)) { // if the entire is not a number
alert( "' " + num + " ' is not a valid entry and that field will " + "not be included in the total money calculation." );
return 0; } else return sum; // if it is OK, send sum back }
function money(form) { hun = s(form.hun.value, 100); // Each amount is the returned value fif = s(form.fif.value, 50); // for the amount in the s() function twe = s(form.twe.value, 20); ten = s(form.ten.value, 10); fiv = s(form.fiv.value, 5); two = s(form.two.value, 2); one = s(form.one.value, 1); hlf = s(form.hlf.value, .5); qtr = s(form.qtr.value, .2); dme = s(form.dme.value, .1); nck = s(form.nck.value, .05); sxw = s(form.sxw.value, .02); pny = s(form.pny.value, .01);
// add up all the amounts var ttl = hun + fif + twe + ten + fi </TEXTAREA> <BR> <script type="text/javascript"><!-- google_ad_client = "pub-7109050768300795"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; google_ad_channel =""; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <BR><BR> <INPUT name=Button onclick=runEx() type=button value=预览效果 style="background-color: #FFFFFF"> <INPUT name=Button onclick=asdf.select() type=button value=全选代码 style="background-color: #FFFFFF"> <INPUT name=Button onclick="asdf.value=''" type=button value=清空代码 style="background-color: #FFFFFF"> <INPUT name=Button onclick="JM_cc('textfield')" type=button value=复制代码 style="background-color: #FFFFFF"> <INPUT onclick=saveFile(); type=button value=保存代码 style="background-color: #FFFFFF"> <INPUT a href="#" onclick="window.open('http://WWW.XFBBS.Com')" type=button value=本站首页 style="background-color: #FFFFFF"> <INPUT onclick="javascript:self.close()" type=button value=关闭窗口 style="background-color: #FFFFFF"></DIV> </TD></TR> <TR> <TD width="50%" height="1" class=mtf> </TD> </TR> </table> </form> </body> </html>
</html> |