为什么我的Button不能运行方程
发表在JavaScript答疑区 2020-04-13
是否精华
版块置顶:


<html>

<head>

<style>

body{margin:0px;}

#orderForm, #confirmForm{postion:absolute; width:280px; height:440px; margin:5px; display:inline-block; padding:5px;}

#orderForm{background-color:#abc; display:inline-block;}

#confirmForm{position:absolute; background-color:#def; }

#bttn{position:absolute; bottom:15px;}

#msg{color:F23; font-weight:bold;}

</style>

</head>


<body>

<div id="orderForm">

<h3>Stationery Order</h3>

<h5>Please complete the form</h5>

<p><input type="text" id="firstName"  placeholder="Enter Your First Name" /></p>

<p><input type="text" id="familyName" placeholder="Enter Your Famiy Name" /></p>

<p>Select Title</p>

<input type="radio" name="citizen" value="cn" checked />Chinese Style

<input type="radio" name="citizen" value="wn" />Western Style

<p>

<input type="radio" name="titles" value="Prof." />Prof.

<input type="radio" name="titles" value="Dr."   />Dr.

<input type="radio" name="titles" value="Mr."   />Mr.

<input type="radio" name="titles" value="Ms."   />Ms.</p>


<input type="checkbox" id="otherChk" name="other" />other

<input type="text" id="otherTitle" placeholder="Enter Your Title" />

<br><br>

<input type="checkbox" id="pen" name="orders" value="Pen" />Pen

<input type="checkbox" id="ruler" name="orders" value="Ruler" />Ruler<br>

<input type="checkbox" id="notepad" name="orders" value="Notepad" />Notepad

<input type="checkbox" id="clips" name="orders" value="Paper Clips" />Paper Clips<br>

<input type="checkbox" id="stapler" name="orders" value="Stapler" />Stapler

<input type="checkbox" id="paper" name="orders" value="Paper(A4" />Paper(A4)


<p><button id="orderBtn" onclick="Order()">Order</button></p>

<p id="msg"></p>

</div ><!-- id="orderForm" -->

<div id="confirmForm">

<div id="printTitle"></div>

<div id="printOrder"></div>

<p id ="bttn"> 

<button id="confirmBtn" onclick="Confirm()" disabled >Confirm Order</button>

<button id="cancelBtn" onclick="Cancel()">Cancel Order</button></p>


</div ><!-- id="confirmForm" -->


<script>


function Order(){

var FIN=document.getElementById("firstName").value;

var FAN=document.getElementById("familyName").value;

var ST=document.getElementsByName("citizen");

for(i=0;i<ST.length;i++){

if(ST[i].checked==true){

var st=ST[i].value;

}

}

var TT=document.getElementsByName("titles");

var tt=[]

for(i=0;i<TT.length;i++){

if(TT[i].checked==true){

tt.push(TT[i].value);

}

}

var OT=document.getElementsByName("other");

var ot=[]

for(i=0;i<OT.length;i++){

if(OT[i].checked==true){

ot.push(OT[i].value);

}

}

var othertitle=document.getElementById("otherTitle").value;

var OR=document.getElementsByName("orders");

var or=[]

for(i=0;i<OR.length;i++){

if(OR[i].checked==true){

or.push(OR[i].value);

}

}

if((FIN=""||FAN="")||(tt=""&&ot="")||or==""){

document.getElementById("printTitle").innerHTML+="Confirm Order"+<br>;

if(FIN=""||FAN=""){

document.getElementById("printTitle").innerHTML+="Please enter all your names"+<br>;

}

if(tt=""&&ot=""){

document.getElementById("printTitle").innerHTML+="Select a title or click the check box"+<br>;

}

if(or==""){

document.getElementById("printTitle").innerHTML+="Click at least one check box"+<br>;

}

}else{

document.getElementById("printTitle").innerHTML+="Confirm Order"+<br>;

document.getElementById("printTitle").innerHTML+="Please confirm the order"+<br>;

if(st=="cn"){

document.getElementById("printTitle").innerHTML+="Dear"+tt+FAN+FIN+<br>+"thank you for your order of";

for(i=0;i<or.length;i++){

document.getElementById("printOrder").innerHTML+=or[i]+<br>;

}

}

if(st=="wn"){

document.getElementById("printTitle").innerHTML+="Dear"+tt+FIN+FAN+<br>+"thank you for your order of";

for(i=0;i<or.length;i++){

document.getElementById("printOrder").innerHTML+=or[i]+<br>;

}

}

}


function Cancel(){

document.getElementById("printTitle").innerHTML="";

document.getElementById("printOrder").innerHTML="";

}


function Confirm(){

var FIN=document.getElementById("firstName").value;

alert("We are sending your order now"+FIN);

}


</script>

</body>

</html>


分享到:
精彩评论 2
hhhtwwq
学分:4 LV1
2020-04-13
沙发

各位前辈救命啊

JAVA13533650592
学分:1685 LV9
2020-04-15
板凳
what is this
首页上一页 1 下一页尾页 2 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照