qq_32816545 于 2016.04.11 20:36 提问

1、下拉列表：选择医院等级（一级，二级，3级）
2、选择成年人还是未成年人
3、输入符合报销范围医疗费用
4、点击计算
5、显示计算结果

（1）起付线：一级医疗机构及以下定点医疗机构100元，二级定点医疗机构300元，三级定点医疗机构800元。
（2）报销比例：一档成年人在一级医疗机构及以下定点医疗机构住院按80%报销，二级定点医疗机构按60%报销，三级定点医疗机构按40%报销。二档在一档基础上报销比例增加5%，未成年人在成年人基础上报销比例增加5%。

3个回答

AIRE_Talent   2016.04.11 21:50

wangjianyu0115   2016.04.11 22:02

<!DOCTYPE html>

``````    <select id="select2">
<option value="5">成年人</option>
<option value="6">未成年人</option>
</select>

输入符合范围金额:<input type="text" id="input1" />
<input type="button" value="计算" onclick="calculate()" />

<script type="text/javascript">
function calculate() {
var levels = document.getElementById("select1").options;
var level;
for (var i = 0, len = levels.length; i < len; i++)
if (levels[i].selected == true)
level = levels[i].value;

var ages = document.getElementById("select2").options;
var age;
for (var i = 0, len = ages.length; i < len; i++)
if (ages[i].selected == true)
age = ages[i].value;

var money = document.getElementById("input1").value;
var percent = 0.0;
if(age == "6")
percent = 0.05;

if(level == "1") {
percent += 0.8;
var fmoney = Number(money);
fmoney -= 100;
fmoney *= percent;
}
else if(level == "2") {
percent += 0.6;
var fmoney = Number(money);
fmoney -= 300;
fmoney *= percent;
}
else if(level == "3") {
percent += 0.4;
var fmoney = Number(money);
fmoney -= 800;
fmoney *= percent;
}
}
</script>
</body>
``````

``````
``````
wangjianyu0115   2016.04.11 22:03

<!DOCTYPE html>

``````    <select id="select2">
<option value="5">成年人</option>
<option value="6">未成年人</option>
</select>

输入符合范围金额:<input type="text" id="input1" />
<input type="button" value="计算" onclick="calculate()" />

<script type="text/javascript">
function calculate() {
var levels = document.getElementById("select1").options;
var level;
for (var i = 0, len = levels.length; i < len; i++)
if (levels[i].selected == true)
level = levels[i].value;

var ages = document.getElementById("select2").options;
var age;
for (var i = 0, len = ages.length; i < len; i++)
if (ages[i].selected == true)
age = ages[i].value;

var money = document.getElementById("input1").value;
var percent = 0.0;
if(age == "6")
percent = 0.05;

if(level == "1") {
percent += 0.8;
var fmoney = Number(money);
fmoney -= 100;
fmoney *= percent;
}
else if(level == "2") {
percent += 0.6;
var fmoney = Number(money);
fmoney -= 300;
fmoney *= percent;
}
else if(level == "3") {
percent += 0.4;
var fmoney = Number(money);
fmoney -= 800;
fmoney *= percent;