信息时代的生存哲学

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

<html>
<head>
<script type="text/javascript">
<!--
function Attachment(maxatts){
var attHTML = '<!--Attachment--><div><input type="hidden" name="attachprem" value="0" />'
 + '<table cellspacing="0" cellpadding="0"><tbody>' +
 '<tr><td style="vertical-align:top;"><img src="./images/paperclip.gif" alt="附件"/>&nbsp;</td>'
 +
 '<td id="att" style="font-size:10pt;"><div id="ia"><span class="l" onclick="javascript:initattachment(this);">上传附件</span></div>'
 +
 '<div id="aa" style="display:none;"><span class="l" onclick="javascript:addattachment(this);">增加附件</span></div></td>'
        +
 '</tr></tbody></table>' + '</div><!--/end Attachment-->' ;
document.write(attHTML);
if(maxatts)
MAX_attachments = maxatts;
}


//////////Attachments Operations!
var VT_attachments = 0;
var MAX_attachments = 5;

function initattachment(me)
{
    var ia = me.parentNode;
    var att = ia.parentNode;
    if(att.id != 'att')
        return;
   
    Ohidden(ia);
    var aa = gObId('aa');
    Oshow(aa);
    addattachment(aa);
//    VT_attachments ++;
}

function addattachment(me)
{
    var attach = document.createElement('div');
    var aa = gObId('aa');
    var att = aa.parentNode;
    if(att.id != 'att')
        return;
   
    attach.innerHTML = '<span style="font-size:10pt;"><input type="file" name="attach[]" />&nbsp;附件描述:<input type="text" name="attachdesc[]" style="width:200px;" maxlength="50" />&nbsp;</span><span class="l" onclick="javascript:delattachment(this);" style="font-size:10pt;">删除</span>';
   
    att.insertBefore(attach,aa);
    VT_attachments ++ ;
    if(VT_attachments >= MAX_attachments)
    {
        Ohidden(aa);
    }
}

function delattachment(me)
{
    var attach = me.parentNode;
    var att = attach.parentNode;
    if(att.id != 'att')
        return;
    att.removeChild(attach);
   VT_attachments -- ;
    if(VT_attachments == 0)
    {   
        Ohidden(gObId('aa'));
        Oshow(gObId('ia'));
    }else if(VT_attachments < MAX_attachments)
        Oshow(gObId('aa'));

 
}

//Elements Operations
function Oshow(e)
{
    e.style.display = "";
}
function Ohidden(e)
{
    e.style.display = "none";
}
function gObId(id)
{
 try{
        return document.getElementById(id);
    }
    catch(e){
        return null;
    }
}
function isOshow(e)
{
    return !(e.style.display == 'none');
}

//-->
</script>
<style>
.l {color:#0000cc;text-decoration:underline;cursor:pointer;cursor:hand;}
</style>
</head>
<body>
<script type="text/javascript">Attachment(10);</script>
</body>
</html>

posted on 2004-09-09 11:51  信息时代的生存哲学  阅读(2094)  评论(0)    收藏  举报