在此页面的底部,您将看到“在此处输入 EFC”的输入框。
JS 文件在这里... JavaScript 文件
输入 EFC 分数时(出于测试目的,使用 0 到 600 之间的任何数字),我希望用户能够选择其中一个按钮,因为可能有两个可能的值,具体取决于所选的按钮。
我想为一个按钮编写一个脚本,为另一个按钮编写另一个脚本。这是我在 HTML 中的代码...
<form onsubmit="showpell_12_13(this.efc.value); return false;">
<form onsubmit="showpell_13_14(this.efc2.value); return false;">
<div align="center"><strong><em>EFC Calculator:</em></strong></p><br />
<div align="center"><input type="text" name="efc" placeholder="Enter EFC Here" value="Enter EFC here..." onblur="if(this.value == ''){ this.value = 'Enter EFC here...'; this.style.color = '#ebebeb';}" onfocus="if(this.value == 'Enter EFC here...'){ this.value = ''; this.style.color = '#000';}" style="color:#000000;" title="EFC Calculator" maxlength="5"/>
</div><br />
<!--placeholder="Enter EFC Here" serves as placeholder for all browsers. Does not work for IE9 or below, hence the included JS, which allows placeholder in IE8-->
<input type="submit" value="EFC - 12 / 13" style="margin-bottom: 10px; width: 40%;" />
<input type="submit" value="EFC - 13 / 14" style="margin-bottom: 10px; width: 40%;" /><br />
<input type="reset" value="Reset" style="margin-bottom: 10px; width: 31%;"/>
</form>
这是我创建的 JS 文件的示例...
function showpell_12_13(efc) {
var pell;
var ssg;
var estpay;
var monthpay;
if (efc == 0) {
pell = 5550;
ssg = 0;
estpay = -483;
monthpay = 0;
}
else if (efc <= 100) {
pell = 5500;
ssg = 0;
estpay = -433;
monthpay = 0;
}
else if (efc < 200) {
pell = 5400;
ssg = 0;
estpay = -333;
monthpay = 0;
}
else if (efc < 300) {
pell = 5300;
ssg = 0;
estpay = -233;
monthpay = 0;
}
else if (efc < 400) {
pell = 5200;
ssg = 0;
estpay = -133;
monthpay = 0;
}
else if (efc < 500) {
pell = 5100;
ssg = 0;
estpay = -33;
monthpay = 0;
}
else if (efc < 600) {
pell = 5000;
ssg = 67;
estpay = 0;
monthpay = 0;
}
confirm('Based on the 2012-2013 EFC you entered ('+efc+'), you may receive...'
+' \n.........................................................'
+' \n-Potential PELL Grant Award: $'+pell+'.'
+' \n.........................................................'
+' \n-Potential Student Success Grant: $'+ssg+'.'
+' \n.........................................................'
+' \n-Tuition of 36 credits: $14,472'
+' \n.........................................................'
+' \n-Direct Loan maximum for a Freshman* student: $9,405**'
+' \n.........................................................'
+' \n-Your estimated total payment: $'+estpay+'.'
+' \n.........................................................'
+' \n-Your estimated monthly payment: $'+monthpay+'.'
+' \n.........................................................'
+' \n *Note: This is only configured for 1st year undergraduate students.'
+' \n **Loan fees of 1% are included in the loan rates listed on this sheet.');
}
我为另一个按钮所做的是复制相同的脚本并创建第二个“.js”文件,然后将变量从“efc”更改为“efc2”。但它没有用。
我希望我的解释足够清楚。如果您需要更多信息,请与我们联系。
这是一个可能有帮助的jsfiddle 。但是,它不会允许您在 jsfiddle 中提交表单......