2012-08-12 123 views
0

我需要在單擊提交按鈕時在同一頁上創建一個表。如何使用jQuery來執行此操作。表格是在提交形式.. Plz幫助..在表單提交中在同一頁面顯示數據

+0

您正在尋找使用AJAX做到這一點?你堅持什麼?需要更多信息才能爲您提供有用的答案。 – Brad 2012-08-12 06:09:44

+0

不,我需要使用jQuery .. – shaz 2012-08-12 06:11:48

+0

你需要點擊按鈕,然後表中將創建一些值,並在同一頁中的所有這些? – themis 2012-08-12 06:13:21

回答

2

這有幫助嗎?

<html> 
<head> 
<script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script> 
<script type="text/javascript" > 
//$(document).ready(function() { 
function submitbutton() 
{ 
    $('#myTable').append('<tr><td>my data</td><td>more data</td></tr>'); 
    $('#myTable').append('<tr><td>my data</td><td>more data</td></tr>'); 
    $('#myTable').append('<tr><td>my data</td><td>more data</td></tr>'); 
    $('#myTable').append('<tr><td>my data</td><td>more data</td></tr>'); 
    $('#myTable').append('<tr><td>my data</td><td>more data</td></tr>'); 
    $('#myTable').show(); 
} 
//}); 

</script> 
</head> 
<body> 
<table id="myTable" style="display:none;border:1px solid #000000;"></table> 
<input type="button" value="submit" onclick="submitbutton()"> 

</body> 
</html> 
+0

是的,非常感謝很多朋友..完美的作品! – shaz 2012-08-12 06:49:44

+0

這裏也是一個關於添加html表格的jqeury教程 http://forum.jquery.com/topic/create-html-table-dynamically – themis 2012-08-12 06:50:53

+0

和更多在這裏http://www.packtpub.com/article/using- jquery-script-for-creating-dynamic-table-of-contents – themis 2012-08-12 06:51:45

相關問題