html5 的一个应用
关于html的这块的文章最近没怎么写,学习的生活比较忙啊,忙!所以今天给大家分享一个我做的应用吧,是用html+css+javascript做的一个市场价转换。大家可以看一看,有什么不好的可以给我提一提建议!
html文件:
var i=1;var j=3;var array1=new Array;var array2=new Array;var array3="";var sumMoney=0;function zhuanhuan(){ var p1=document.getElementById('xin1').value; var p2=parseInt(document.getElementById('xin2').value); var p3=parseInt(document.getElementById('xin3').value); var xxx=document.getElementById('x').value; if(p3==0) { alert(xxx); return; } document.getElementById('steps'+j).style.display=''; var p4=String(document.getElementById('xiala').value); var p5; if(p4="斤") { p5=p2/(p3/2); document.getElementById('pq'+i+'1').value=p1+" "+p5.toFixed(2); array1[i]=p2; array2[i]=p1; } var p6; if(p4="两") { p6=p2/(p3/20); document.getElementById('pq'+i+'1').value=p1+" "+p6.toFixed(2); array1[i]=p2; array2[i]=p1; } var p7; if(p4="克") { p7=p2/(p3/1000); document.getElementById('pq'+i+'1').value=p1+" "+p7.toFixed(2); array1[i]=p2; array2[i]=p1; } var p8; if(p5="千克") { p8=p2/p3; document.getElementById('pq'+i+'1').value=p1+" "+p8.toFixed(2); array1[i]=p2; array2[i]=p1; } i++; j++; document.getElementById('xin1').value=""; document.getElementById('xin2').value=""; document.getElementById('xin3').value=""; document.getElementById('navigation').style.display='';}function result(){var sum=0;//var j=1;document.getElementById('jghz').style.display='';document.getElementById('navigation').style.display='none';document.getElementById('navigation2').style.display='';for(var m=1,n=1;m<17,n<17;m++,n++){ if(document.getElementById('pq'+m+3).checked==true) { //alert("hello"); sum=sum+parseInt(document.getElementById('pq'+m+2).value)*array1[m]; // alert(array1[i]); array3=array3+"\n"+array2[m]+":"+array1[m]+" yuan"; document.getElementById('l'+m).innerHTML=array2[m]; document.getElementById('l'+m).style.display=''; document.getElementById('i'+m).value=array1[m]*parseInt(document.getElementById('pq'+m+2).value)+" yuan"; document.getElementById('i'+m).style.display=''; // document.getElementById('shuchu').value=array2[i]+" "+array1[i]; document.getElementById('pq'+m+3).checked=false; }}for(var x=3;x<17;x++){ document.getElementById('steps'+x).style.display="none";}//alert(sum);//array3=array3+"\n"+"sumMoney:"+sum.toString()+" yuan";//document.getElementById('shuchu').value=array3;sumMoney=sumMoney+sum;document.getElementById('l20').innerHTML=document.getElementById('xxx').value+sumMoney.toString()+" yuan";document.getElementById('l20').style.display='';//alert(sumMoney);}function jie1(){ document.getElementById('jiemian1').style.display='none'; document.getElementById('wrapper').style.display='';}function jie2(){document.getElementById('jiemian1').style.display='none'; document.getElementById('jiemian3').style.display='';}function fanhui1(){ document.getElementById('wrapper').style.display='none'; document.getElementById('jiemian1').style.display='';}function fanhui2(){ document.getElementById('jiemian3').style.display='none'; document.getElementById('jiemian1').style.display='';}var sum=0;function goumai(){var cur; cur=parseInt(document.getElementById('ipt1').value); // alert(cur); var temp=parseInt(document.getElementById('ipt2').value); sum+=temp; // alert(sum); document.getElementById('ipt2').value=""; if(sum>=cur) { document.getElementById('shang1').style.display='none'; document.getElementById('ipt2').style.display='none'; document.getElementById('shang2').style.display=''; document.getElementById('ipt3').style.display=''; document.getElementById('ipt3').value=sum; } }