Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  48] [ 6]  / answers: 1 / hits: 11976  / 11 Years ago, tue, december 17, 2013, 12:00:00

Please advise how to achieve that hide the html inner table when page loading and click the search button, table will display with results only. I don't want to show the empty table. Please see the below code which I have tried.


But sure, after click the button page is getting refresh.


$(document).ready(function() {       

$("#historylist").hide();

$("#historysearch").click(function() {
$("#historylist").show();
});
// }
});

<table id="searchTbl" width="800" >
<tr>
<td valign="top">Release No</td>
<td valign="top">
<input type="text" name="releaseNo" value="" style="width:200" />
</td>
<td valign="top"><input type="button" value="Search" onClick="commit()" style="width:80" id="historysearch"/></td>
</tr>
<br /><br />

<table border="1" cellpadding="2" cellspacing="0" id="historylist">
<tr>
<th><font size="-1">Header1</font></th>
<th><font size="-1">Header2</font></th>
<th><font size="-1">Header3</font></th>
<th><font size="-1">Header4</font></th>
<th><font size="-1">Header5</font></th>
</tr>
</table>
</table>

JavaScript:


function commit(){

document.menu.cmd.value='search';
document.menu.submit();
}

When click the button it show the table and again hiding the table.


$(document).ready(function() { 
$("#historylist").hide();
$("#historysearch").click(function(e) {
e.preventDefault();
$("#historylist").show();
commit(); // moved from the onClick attribute });
});

More From » jquery

 Answers
2
$(#historysearch).click(function(e) {
e.preventDefault();
$(#historylist).show();
commit(); // moved from the onClick attribute
});




http://api.jquery.com/event.preventDefault/


[#49440] Tuesday, December 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ellisw

Total Points: 625
Total Questions: 92
Total Answers: 88

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
ellisw questions
Mon, Aug 23, 21, 00:00, 3 Years ago
Fri, Nov 20, 20, 00:00, 4 Years ago
Sat, Jun 20, 20, 00:00, 4 Years ago
Tue, Apr 21, 20, 00:00, 4 Years ago
;