微信公开课小程序热门讨论「C#商店计费打折小程序」最新回复-应付金额:inputname=textfieldtype=textid=TruePricewidth=30pxmaxlength=10onchange=GetPrice();/打折:selectname=selectid=zheonchange=GetPrice();optionvalue=one一折/optionoptionvalue=five五折/optionoptionvalue=seven七折/optionoptionvalue=eight八折/optionoptionvalue=nine九折/option/select实收金额:inputname=textfield2type=textid=Discountwidth=30pxmaxlength=10/因无开发工具就写了JSscripttype=text/javascriptfunctionGetPrice(){varTruePrice=document.getElementById(TruePrice).value;//应收金额varZhe=document.getElementById(zhe);//打折varcalue=Zhe.options[Zhe.selectedIndex].text;switch(calue){case一折:calue=0.1;break;case五折:calue=0.5;break;case七折:calue=0.7;break;case八折:calue=0.8;break;case九折:calue=0.9;break;}vara=Number(calue)*Number(TruePrice);document.getElementById(Discount).value=a;//实收金额}/script在C#的开发环境中可以在打折这个下拉框的一个Select事件中进行计算
/*方法一 doublesum=0; doublenum1=double.Parse(this.textTotalMoney.Text); doublenum2=double.Parse(this.textZHEKOU.Text); sum=num1*num2/100; this.textFactMoney.Text=sum.ToString(); */ //方法二 this.ShowPrice();privatevoidShowPrice(){ if(this.textTotalMoney.Text==) { this.textTotalMoney.Text=; return; } doubletextBox1=Convert.ToDouble(this.comboBox1.Text); doubleprice=Convert.ToDouble(this.textTotalMoney.Text)*textBox1/10.0; this.textFactMoney.Text=price.ToString();}privatevoidtextTotalMoney_KeyPress(objectsender,KeyPressEventArgse){ if((e.KeyChar0||e.KeyChar9)&&e.KeyChar!=8)//只允许显示数字 { e.Handled=true; }}本回答被提问者采纳 更多有关「C#商店计费打折小程序」的疑问请扫码关注微信公开课+小程序!了解更多