innerHTML

通过javascript动态显示界面控件作者:windfly.  转自:http://windfly.blog.ccidnet.com/  点击:68  发布日期:2008-5-10 <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,否则会导致“网页上有错误”。

你可能感兴趣的:(innerHTML)