通过javascript动态显示界面控件
作者: zyf0808 发表日期: 2006-03-30 08:47 文章属性: 原创 复制链接


<script language="javascript">
function ShowAddSub()
{
var str_inner;
str_inner = "<form method=post action=\"tp_update_cat.asp\" name=\"AddSubForm\">New Category Name: <input type=text name=newsubname value=\"\">
<input type=submit name=op1 value=\"Add\" style=\"background-color:#FFFFFF;font-family: verdana;\"> ";
str_inner = str_inner + "<a href=\"javascript:HideAddSub()\"><img src=\"p_w_picpaths\\org.gif\" border=0 alt=\"Hide\"></a>";
str_inner = str_inner + "<input type=hidden name=op value=\"AddCat\">";
str_inner = str_inner + "<input type=hidden name=parent_dept value=\"08\">";
str_inner = str_inner + "<input type=hidden name=dept_level value=\"1\">";
str_inner = str_inner + "<input type=hidden name=is_product value=\"0\">";
str_inner = str_inner + "</form>";
 
SubAdd.innerHTML = str_inner;
}
 
function HideAddSub()
{
var str_inner;
str_inner = "[<a href=\"javascript:ShowAddSub()\">Add a New Category Here</a>]";
                           
SubAdd.innerHTML = str_inner;
}
<script>
 
<SPAN id="SubAdd">[<A href="javascript:ShowAddSub()">Add a New Category Here</A>]</SPAN>
 
当点击链接时,就会显示出一个文本框和两个按钮,注意,不要将span放入form中,因str_inner中已经定义了一个form,否则会导致“网页上有错误”。