Friday, 2 March 2012

how to save data in temporary table using jquery without using database

design the page :
 <form id="form1" runat="server">
    <div>
    <center>
    <table>
    <tr><td>EID</td><td><asp:TextBox ID="tb" runat="server"></asp:TextBox></td></tr>
     <tr><td>NAME</td><td><asp:TextBox ID="tb1" runat="server"></asp:TextBox></td></tr>
     <tr><td>&nbsp;</td><td><asp:Button ID="btn" runat="server"  Text="Save" Width="80"/></td></tr>
     <tr><td>&nbsp;</td><td><table id="ta" border="1" width="100%"><tr><th>EID</th><th>NAME</th></tr></table></td></tr>
    </table>
    </center>
    </div>
    </form>
page looks like:

Add script on top

<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 
<script type="text/javascript">
 $(document).ready
(
function ()
{
    $("#btn").click
(
function ()
 {
    $("#ta").append("<tr><td>" + $("#tb").val() + "</td><td>" + $("#tb1").val() + "</td></tr>");
    return false
}
)
}
)
</script>

1 comment: