<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=\"images\\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,否则会导致“网页上有错误”。
本文转自 august 51CTO博客,原文链接:http://blog.51cto.com/august/6963,如需转载请自行联系原作者