如果是asp就简单了。
<%if n=1 then%>
...
<%else if n=2 then%>
...
<%end if%>js的如下:<INPUT TYPE="text" NAME="txt1"><INPUT TYPE="button" value="change" onclick="changeStyle();">
<table width="100%" border="0"><tr><td>
<table width="100%" border="0"><tr><td>这里输出表格
<script language=javascript>
function changeStyle(){
var n;
n=txt1.value;
if(n==1){
document.write("<table width='100%' border=0'><tr><td>");
document.write("<table width='90%' border='0'><tr><td>这是表格1</td></tr></table>");
document.write("</td></tr></table>");
}else if(n==2){
document.write("<table width=100% border=0><tr><td>");
document.write("<table width=80% border=0><tr><td>这是表格2</td></tr></table>");
document.write("</td></tr></table>");
document.write("</td></tr></table>");
}
}
</script>
</td></tr></table>

解决方案 »

  1.   

    var tableBox = '<table width="100%" border="0"><tr><td>';
    if (n == 1)
      tableBox += '<table width="90%" border="0"><tr><td>这是表格1</td></tr></table>';
    if (n == 2)
      tableBox += '<table width="80%" border="0"><tr><td>这是表格2</td></tr></table>';
    tableBox += '</td></tr></table>';
    document.write(tableBox);
      

  2.   

    能不能使“<table width="100%" border="0"><tr><td>这里输出表格</td></tr></table>”是静态的htm,嵌入的表格是动态生成的?
      

  3.   

    <INPUT TYPE="text" NAME="txt1"><INPUT TYPE="button" value="change" onclick="changeStyle();">
    <script language=javascript>
    function changeStyle(){
    var n;
    n=txt1.value;
    if(n==1){
    htmlinfo="<table width='100%' border=0'><tr><td>"
    htmlinfo+="<table width='90%' border='0'><tr><td>这是表格1</td></tr></table>"
    htmlinfo+="</td></tr></table>"
    }else if(n==2){
    htmlinfo="<table width='100%' border=0'><tr><td>"
    htmlinfo+="<table width='80%' border='0'><tr><td>这是表格2</td></tr></table>"
    htmlinfo+="</td></tr></table>"
    }else{
    htmlinfo="<p>请输入1、2";
    }
    document.all.showtxt.innerHTML=htmlinfo
    }
    </script>
    <table width="100%" border="0"><tr><td>
    <table width="100%" border="0"><tr><td>这里输出表格<span id=showtxt></span>
    </td></tr></table>