要求是这样的,单击某个按钮就清除掉该按钮,功能类似于购物车中的去掉某个商品(其中按钮是变量,通过从上级页面中传递过来.为了方便阅读,我在下面代码中直接放入了3个按钮).先在此谢谢各位了!
<!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=gb2312" />
<SCRIPT LANGUAGE="JavaScript">
<!--
function getCookie( name )
{
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}// ---------------------------------------------------- //
function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+'='+escape( value ) +
( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
( ( path ) ? ';path=' + path : '' ) +
( ( domain ) ? ';domain=' + domain : '' ) +
( ( secure ) ? ';secure' : '' );
}// ---------------------------------------------------- //
function deleteCookie( name, path, domain )
{
if ( getCookie( name ) ) document.cookie = name + '=' +
( ( path ) ? ';path=' + path : '') +
( ( domain ) ? ';domain=' + domain : '' ) +
';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}function on_del_click(cookie_name)
{
//document.cookie = cookie_name+"=";
deleteCookie(cookie_name);
window.open("test.html", "_self", "");
return false;
}
//-->
</SCRIPT>
</head><body><form action='ok.asp' method='post'><input type='button' onclick='return on_del_click("aaa");' value="aaa">
<br>
<input type='button' onclick='return on_del_click("bbb");' value="bbb">
<br>
<input type='button' onclick='return on_del_click("ccc");' value="ccc">
</form>
</body>
</html>