<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript" src="javascripts/prototype.js"></script>
<script language="javascript" type="text/javascript" src="javascripts/window.js"></script>
<script language="javascript" type="text/javascript" src="javascripts/effects.js"></script>
<link href="css/themes/default.css" rel="stylesheet" type="text/css" />
<link href="css/themes/spread.css" rel="stylesheet" type="text/css" />
<link href="css/themes/alert.css" rel="stylesheet" type="text/css" />
<link href="css/themes/alert_lite.css" rel="stylesheet" type="text/css" />
<link href="css/themes/alphacube.css" rel="stylesheet" type="text/css" />
<link href="css/themes/debug.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="login" style="display:none">
<p><span id='login_error_msg' class="login_error" style="display:none"> </span></p>
<div style="clear:both"></div>
<p><span class="login_label">交纳资费金额:</span> <span class="login_input"><input type="text" name="name" size="10" />(元)</span></p>
<div style="clear:both"></div>
<p><span class="login_label">服务终止时间:</span> <span class="login_input"><input type="text" name="pass" size="20"/>(如2008-8-8)</span></p>
<div style="clear:both"></div>
</div>
<!-- ------------------------------e ------------------------- -->
<table width="800" border="0" align="center">
<tr>
<td><b>单位名称</b></td>
<td><b>注册时间</b></td>
<td><b>会员类型</b></td>
<td ><b>操作</b></td>
</tr>
<tr id="3">
<td><div>豪杰科技</div></td>
<td><div>2006-5-8</div></td>
<td><div>普通单位</div></td>
<td>
<button id="delete" value="3" >删除</button>
<button id="vip" value="3" >设为VIP</button>
<button id="huiyuan" value="3" >设为会员</button>
<button id="normal" value="3" style="display:none">设为普通</button>
</td>
</tr>
<tr id="4">
<td><div>豪杰科技</div></td>
<td><div>2006-5-8</div></td>
<td><div>VIP单位</div></td>
<td>
<button id="delete" value="4">删除</button>
<button id="vip" value="4" style="display:none">设为VIP</button>
<button id="huiyuan" value="4" >设为会员</button>
<button id="normal" value="4" >设为普通</button>
</td>
</tr>
<tr>
</tr>
</table>
<!-- 注册事件 -->
<script type="text/javascript">
//当页面加载完毕后调用事件注册函数
Event.observe(window, 'load',function(){
//为所有的按钮注册事件
$$('button').each(function(item){
var type = item.readAttribute('id');
if(type == 'delete'){//如果是删除按钮事件
item.observe('click', doDelete);
}else if(type == 'vip'){//如果是vip按钮事件
item.observe('click', doVIP);
}else if(type == 'huiyuan'){//如果是普通会员按钮
item.observe('click', doHuiyuan);
}else if(type == 'normal'){
item.observe('click', doNormal);
}
});
});
</script>
<!-- ---------------------提升为会员 ------------------------- -->
<script type="text/javascript">
function doHuiyuan(event){
var element = Event.element(event);
Dialog.confirm($('login').innerHTML,
{className:"alphacube", width:400,
okLabel: "确定", cancelLabel: "取消",
onOk:function(win){
startHuiyuanAjax(element);
return true;
}
}
);
}
//开始ajax
function startHuiyuanAjax(element){
new Ajax.Request('JSONExample.action',
{ method:'get',
//requestHeaders: {Accept: 'application/json'},
parameters: {id: element.readAttribute('value'),name: $F('name'), pass: $F('pass')},
onSuccess: function(transport){
var response = transport.responseText.evalJSON(true);
var flag= response.login;
if(flag){
var tds=$(element.readAttribute('value')).childElements();
var td3=tds.first().next(1);
var divs3=td3.childElements().first();
divs3.replace('<div>会员单位</div>');
element.previous(0).show();
element.next(0).show();
element.hide();
alert("OK , 操作成功!");
}else{
alert("操作失败!");
}
},
onFailure: function(){
alert('可能后台出现了错误...');
}
});
}
</script>
<!-- -----------------------提升为VIP-------------------------------- -->
<script type="text/javascript">
function doVIP(event){
var element = Event.element(event);
Dialog.confirm($('login').innerHTML,
{className:"alphacube", width:400,
okLabel: "确定", cancelLabel: "取消",
onOk:function(win){
startVIPAjax(element);
return true;
}
}
);
}
//开始ajax
function startVIPAjax(element){
new Ajax.Request('JSONExample2.action',
{ method:'get',
//requestHeaders: {Accept: 'application/json'},
parameters: {id: element.readAttribute('value'),name: $F('name'), pass: $F('pass')},
onSuccess: function(transport){
var response = transport.responseText.evalJSON(true);
var flag=response.login;
if(flag){
var tds=$(element.readAttribute('value')).childElements();
var td3=tds.first().next(1);
var divs3=td3.childElements().first();
divs3.replace('<div>VIP单位</div>');
//alert(element.readAttribute('id'));
element.next(0).show();
element.next(1).show();
element.hide();
alert("OK , 操作成功!");
}else{
alert("操作失败!");
}
},
onFailure: function(){
alert('可能后台出现了错误...');
}
});
}
</script>
<!-- -------------------降级为普通会员--------------------------- -->
<script type="text/javascript">
function doNormal(event){
if(! confirm("将会降低客户的服务范围,确定这样做吗?")){return ;}//提示
var element = Event.element(event);
new Ajax.Request('JSONExample2.action',
{ method:'get',
//requestHeaders: {Accept: 'application/json'},
parameters: {id: element.readAttribute('value')},
onSuccess: function(transport){
var response = transport.responseText.evalJSON(true);
var flag=response.login;
if(flag){
var tds=$(element.readAttribute('value')).childElements();
var td3=tds.first().next(1);
var divs3=td3.childElements().first();
divs3.replace('<div>普通单位</div>');
//alert(element.readAttribute('id'));
element.previous(0).show();
element.previous(1).show();
element.hide();
alert("OK , 操作成功!");
}else{
alert("操作失败!");
}
},
onFailure: function(){
alert('可能后台出现了错误...');
}
});
}
</script>
<!-- ------------------删除操作------------------------- -->
<script type="text/javascript">
var timeout;
var theNode2;
function doDelete(event) {
if(! confirm("删除将不可恢复,确定要删除吗?")){return ;}//提示
theNode2=Event.element(event);
timeout=1;//设置为等待1秒
Dialog.info("正在删除..." + timeout + "秒",
{width:110, height:40, showProgress: true});
setTimeout(infoTimeout, 1000)
}
function infoTimeout() {
timeout--;
if (timeout >=0) {
Dialog.setInfoMessage("正在删除..." + timeout + "秒");
setTimeout(infoTimeout, 1000);
}else{
Dialog.closeInfo();
$(theNode2.readAttribute('value')).remove();
alert('操作成功!');
}
}
</script>
</body>
</html>
分享到:
相关推荐
用prototype+json三级联动
prototype整合json实现无刷新验证用户名,有详细注释说明。
NULL 博文链接:https://dodomail.iteye.com/blog/251704
开发中用官网上下的json.js的toJSONString()方法总是报没有对象或方法的错误,于是有了这个没有对Object()对象做prototype扩展的json.js
json,jQuery,prototype
json.js json2.js json.jar prototype.js prototype.chm
地图.prototype.tojson ES7 map.prototype.tojson polyfill安装 $ npm install --save map.prototype.tojson用法 require ( 'map.prototype.tojson' ) ;var myMap = new Map ( ) ;myMap . set ( NaN , "not a number...
set.prototype.tojson 用于set.prototype.toJSON() ES7 set.prototype.toJSON()安装 $ npm install --save set.prototype.tojson用法 require ( 'set.prototype.tojson' ) ;var mySet = new Set ( ) ;mySet . add ( ...
三合一的js文件,包括json.js,prototype.js,nav.js 三个js文件,很实用
toJSONString method and a parseJSON method to Object.prototype. Use of this file is not recommended. json_parse.js: This file contains an alternative JSON parse function that uses recursive descent ...
它还增加了atoJSONString方法和parseJSON方法到Object.prototype。使用thisfile recommended.json_parse.js:该文件包含替代JSON的parse函数thatuses递归下降而不是eval.json_parse_state.js:此文件包含替代JSON的...
Ajax + JSON + Servlet + prototype.js(实现的一个Ajax实例) 很好的展示了Ajax与JSON的无缝连接与后台的交互。
针对覆盖的Array.prototype.toJSON和IE8的Date.prototype.toJSON的非标准化版本对JavaScript JSON API进行Date.prototype.toJSON 。 相对于优势 小得多,只有几行而不是4KB 使用本机的stringify和parse方法 在较旧...
json以及与jquery使用时会使用到的包,现提供给大家。 prototype.js是个流行的javascript库,提供了evalJSON()方法
Date.prototype.toJSON = function (key) { function f(n) { // Format integers to have at least two digits. return n ; } return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f...
json for javasript 的範例 敎大家怎樣用prototype去解譯json格式字串
// Add Prototype to JSON, So no need to use variable require ( 'json-hpack' ) // or json_hpack = require ( 'json-hpack' ) var json = [ { name : "Andrea" , age : 31 , gender : "Male" , skilled : ...
解决javascript向服务端提交json数据格式时的拼装问题。 内部使用javabean模式包装javascript对象,使用继承获取 转换json的方法。
例如: 含有占位符的字符串hello,{name},your birthday is {... 实现代码: 代码如下: Object.prototype.jsonToString=function(str) { o=this; return str.replace(/\{\w*\}/g, function (w) { r = w.substr(1,w.l
该实例有prototype.js和effects.js;还涉及有json。。。 推荐有学过的朋友。