Tusk Posted October 25, 2010 Share Posted October 25, 2010 My "<!-- Script Block 1-->" Returns a NAN result when i add "<!-- Script Block 2-->" but if I remove Block 2, Block 1 works? Is there a way I can run the two together on the same page without them clashing?<html> <head> <!-- Script Block 1--><script language='javascript' type='text/javascript'>function calc(data){var cA1A=data.pA1A,cA2A=data.pA2A,cA3A=Math.floor(cA1A/cA2A),cA4A=cA3A*cA2A,cA5A=cA1A-cA4A,cA6A=cA5A>0?cA5A:cA2A;data.pA3A=cA3A;data.pA4A=cA4A;data.pA5A=cA5A;data.pA6A=cA6A}</script><script language='javascript' type='text/javascript'>var eeisus=0,eetrue="TRUE",eefalse="FALSE",eedec=".",eeth=",",eedecreg=new RegExp("\\.","g"),eethreg=new RegExp(",","g")</script><script language='javascript' type='text/javascript'>var co={};function recalc_onclick(){if(true){co.pA1A=eeparseFloat(document.formc.pA1A.value);co.pA2A=eeparseFloat(document.formc.pA2A.value);calc(co);document.formc.pA3A.value=eedisplayFloat(co.pA3A);document.formc.pA4A.value=eedisplayFloat(co.pA4A);document.formc.pA5A.value=eedisplayFloat(co.pA5A);document.formc.pA6A.value=eedisplayFloat(co.pA6A)}}</script><script language='javascript' type='text/javascript'>function myIsNaN(x){return isNaN(x)||typeof x=="number"&&!isFinite(x)}function round(n,nd){if(isFinite(n)&&isFinite(nd)){var sign_n=n<0?-1:1,abs_n=Math.abs(n),factor=Math.pow(10,nd);return sign_n*Math.round(abs_n*factor)/factor}else return NaN}function eeparseFloat(str){str=String(str).replace(eedecreg,".");var res=parseFloat(str);if(isNaN(res))return 0;else return res}var near0RegExp=new RegExp("[.](.*0000000|.*9999999)");function eedisplayFloat(x){if(myIsNaN(x))return Number.NaN;else{var str=String(x);if(near0RegExp.test(str)){x=round(x,8);str=String(x)}return str.replace(/\./g,eedec)}}</script><script language='javascript' type='text/javascript'>var reqlist=[];function reset_onclick();recalc_onclick("")}</script><!-- Script Block 2--><script language='javascript' type='text/javascript'>function calc() {var t = document.getElementById("cipher").value;var numbers = new Array();numbers = t.split(/\s+/);var sum = 0;var num = '';if (numbers.length == 1) { num = '0'; }for (i = 0; i < numbers.length; i++) {sum = sum + eval(numbers); if (i == numbers.length - 1) { num = num + " and ";} else { if (i > 0) { num = num + ", "} } num = num + numbers; }result = "<p>The sum of the numbers " + num + " is " + sum +"<"+"/p>";var resElement = document.getElementById("res");resElement.innerHTML = result;}</script><meta http-equiv='Content-type' content='text/html;charset=UTF-8'><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body bgcolor="#FFFFFF" background="bckgrnd.gif" text="#000000" leftmargin="0" topmargin="0" class="titlestyle"> <div align="center"> <br> <form name="form1" class="textstyle"> <br> <br> <p><br></p> <font color="#0000FF" size="4" face="comic sans ms"><br> <textarea id='cipher' onclick="this.value=''" onchange='calc()'cols = 65 rows = 5 ></textarea> <div id='res'></div> </font> </form> </div> </body> <body> <form id='formc' name='formc' method='post' action=''><table cellspacing='0' cellpadding='0' width='419' style='border-collapse:collapse' align="center"><tr style="height:1px;"><td style="width: 49px"></td><td width='192'></td></tr><tr><td class='ee100' style="width: 49px"><input onchange="this.value=eedisplayFloat(eeparseFloat(this.value));recalc_onclick('pA1A') ;setValueofBtn();" value='211' type='text' tabindex='1' style=' width:100%;padding-right:1px; color: #000000; text-align: right; background-color: #C0C0C0;' name='pA1A' id='pA1A' class='ee102' downkey='pA2A' onKeyDown="onEnterPress('pA1A');" > </td><td class='ee103' colspan='3'> </td></tr><tr style='height:13pt; '><td class='ee100' style="width: 49px"><input onchange="this.value=eedisplayFloat(eeparseFloat(this.value));recalc_onclick('pA2A') ;setValueofBtn();" value='49' type='text' tabindex='2' style=' width:100%;padding-right:1px; color: #000000; text-align: right; background-color: #C0C0C0;' name='pA2A' id='pA2A' class='ee102' onKeyDown="onEnterPress('pA2A');" > </td><td class='ee103' colspan='3'> </td></tr><tr style='height:13pt'><td class='ee109' style="width: 49px"><input type='hidden' value='0' tabindex='-1' style='overflow:hidden; border:0px solid #000000; width:100% ;padding-right:1px;' name='pA3A' id='pA3A' class='ee110' > </td><td class='ee103' colspan='3'><div style="height:13pt;overflow:hidden"></div></td></tr><tr style='height:13pt'><td class='ee109' style="width: 49px" ><input type='hidden' value='0' tabindex='-1' style='overflow:hidden; border:0px solid #000000; width:100% ;padding-right:1px;' name='pA4A' id='pA4A' class='ee110' > </td><td class='ee103' colspan='3'><div style="height:13pt;overflow:hidden"></div></td></tr><tr style='height:14pt'><td class='ee109' style="width: 49px" ><input value='0' name='pA5A' id='pA5A' type='hidden' > </td><td class='ee103' colspan='3'><div style="height:14pt;overflow:hidden"></div></td></tr><tr style='height:14pt; font-family: 'Comic Sans MS'; color: #0000FF; font-size: large; background-color: #FFFFCC; text-align: center;'><td class='ee111' style="width: 49px" ><input readonly='readonly' value='0' type='text' tabindex='-1' style='background: #FFFFCC; overflow:hidden; border:0px solid #000000; width:100%; padding-right:1px; text-align: center; color: #0000FF; font-weight: bold; font-size: large;' name='pA6A' id='pA6A' class='ee113' > </td><td class='ee103' colspan='3'>Result</td><tr style='height:13pt'><td class='ee103' style="width: 49px" ><div style="height:13pt;overflow:hidden"></div></td><td class='ee103' colspan='3'><div style="height:13pt;overflow:hidden"></div></td></tr></table></form></html> Link to comment Share on other sites More sharing options...
BobbyFrankyJim Posted October 25, 2010 Share Posted October 25, 2010 Are they meant to be comments, if so I would suggests using the proper // for 1 line and /* */ for multiple Link to comment Share on other sites More sharing options...
[dx] Posted October 25, 2010 Share Posted October 25, 2010 Also you can't have 2 functions with same name. Use calc1() and calc2()Or you can use this: function calc(what) { if (what == 1) { script 1 here; } else if (what == 2) { script 2 here; }} And when using, use calc(1) or calc(2). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.