Home > Backend Development > PHP Tutorial > php 基础求解,拜托诸位了。小女子这项有礼了!

php 基础求解,拜托诸位了。小女子这项有礼了!

WBOY
Release: 2016-06-13 12:56:18
Original
828 people have browsed it

php 基础求解,拜托各位了。小女子这项有礼了!!!
两个输入框,输入5,3时,在另一个界面出现一个5行3列的表格,前提是用函数实现这个功能.OK??? 


------解决方案--------------------
<br />
	<input type="text" name="a" id="a"/><br />
	<input type="text" name="b" id="b"/><br />
	//提交的路径你自己补上就是<form id="" action=""><br />
	<br />
	$a=$_POST['a'];<br />
	$b=$_POST['b'];<br />
	function table($a,$b){<br />
		echo "<table border=\"1\" cellpadding=\"15\" >";<br />
		for($i=0;$i<$a;$i++){<br />
			echo "<tr>";<br />
			for($j=0;$j<$b;$j++){<br />
				echo "<td>".$j."</td>";<br />
			}<br />
			echo "</tr>";<br />
		}<br />
		echo "</table>";<br />
	}<br />
	table(7,5);<br />
Copy after login

------解决方案--------------------
我猜楼主是要JS实现的那种
<br />
<!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<head><br />
<script language="javascript"><br />
function addTables()<br />
{<br />
    var table_box=document.getElementById("set_table");<br />
    table_box.innerHTML='';<br />
    var tr_count=document.getElementById('set_table_tr').value;<br />
    var td_count=document.getElementById('set_table_td').value;<br />
    if(tr_count && parseInt(tr_count))<br />
    {<br />
        for(var i=0;i<tr_count;i++)<br />
        {<br />
            var new_tr=table_box.insertRow(-1);<br />
            if(td_count && parseInt(td_count))<br />
            {<br />
                for(var j=0;j<td_count;j++)<br />
                {<br />
                    var new_td=new_tr.insertCell(-1);<br />
                    new_td.innerHTML=i*j;<br />
                }<br />
            }<br />
        }<br />
    }<br />
}<br />
</script><br />
</head><br />
<body><br />
<div><br />
行:<input type="text" id="set_table_tr" onkeyup="addTables();"/><br />
列:<input type="text" id="set_table_td" onkeyup="addTables();"/><br />
</div><br />
<div><br />
<table id="set_table" border="1"><br />
</table><br />
</div><br />
</body><br />
</html><br />
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template