本文实例讲述了js捐赠管理完整实现方法。分享给大家供大家参考。具体实现方法如下:
index.html页面如下:
代码如下:<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js捐赠管理</title>
<link href="css/css.css" rel="Stylesheet" type="text/css" />
<script type="text/javascript">
//受捐单位数组
var listOrgs = [
{ "id": "1", "comName": "壹基金" },
{ "id": "2", "comName": "宋庆龄基金" },
{ "id": "3", "comName": "慈济基金" },
{ "id": "4", "comName": "红十字会" },
{ "id": "5", "comName": "狼图腾" }
];
//给listOrgs数组对象动态添加一个匿名方法
listOrgs.getOrgsById = function (id) {
for (var i = 0; i < listOrgs.length; i++) {
if (listOrgs[i].id == id) {
return listOrgs[i];//返回一个对象
}
}
};
//捐款数据数组
var listData = [
{ "id": "1", "perName": "成龙", "orgId": "1", "money": "10000", "date": "2012-3-3" },
{ "id": "2", "perName": "李连杰", "orgId": "2", "money": "10000", "date": "2012-3-3" },
{ "id": "3", "perName": "陈光标", "orgId": "3", "money": "10000", "date": "2012-3-3" },
{ "id": "4", "perName": "胡锦涛", "orgId": "1", "money": "10000", "date": "2012-3-3" },
新闻热点
疑难解答
图片精选