两个输入框,输入5,3时,在另一个界面出现一个5行3列的表格,前提是用函数实现这个功能.OK??? 

解决方案 »

  1.   


    <input type="text" name="a" id="a"/>
    <input type="text" name="b" id="b"/>
    //提交的路径你自己补上就是<form id="" action="">

    $a=$_POST['a'];
    $b=$_POST['b'];
    function table($a,$b){
    echo "<table border=\"1\" cellpadding=\"15\" >";
    for($i=0;$i<$a;$i++){
    echo "<tr>";
    for($j=0;$j<$b;$j++){
    echo "<td>".$j."</td>";
    }
    echo "</tr>";
    }
    echo "</table>";
    }
    table(7,5);
      

  2.   

    我猜楼主是要JS实现的那种<!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <head>
    <script language="javascript">
    function addTables()
    {
        var table_box=document.getElementById("set_table");
        table_box.innerHTML='';
        var tr_count=document.getElementById('set_table_tr').value;
        var td_count=document.getElementById('set_table_td').value;
        if(tr_count && parseInt(tr_count))
        {
            for(var i=0;i<tr_count;i++)
            {
                var new_tr=table_box.insertRow(-1);
                if(td_count && parseInt(td_count))
                {
                    for(var j=0;j<td_count;j++)
                    {
                        var new_td=new_tr.insertCell(-1);
                        new_td.innerHTML=i*j;
                    }
                }
            }
        }
    }
    </script>
    </head>
    <body>
    <div>
    行:<input type="text" id="set_table_tr" onkeyup="addTables();"/>
    列:<input type="text" id="set_table_td" onkeyup="addTables();"/>
    </div>
    <div>
    <table id="set_table" border="1">
    </table>
    </div>
    </body>
    </html>