Hide Form Using Javascript November 26, 2023 Post a Comment Javascript: function next(a) { if(a==1) { document.getElementById('form1').style.display='none'; } } HTML: Solution 1: You need to use return false<form onsubmit="return next(1)" action="add.php" method="post"id="form1"> CopyThenfunctionnext(a) { if(a==1){ document.getElementById("form1").style.display="none"; returnfalse; } } CopyFIDDLE DEMO UPDATE: To Show the form<input type="Submit" value="Show"class="button" onclick="return showForm()" name="show"/> functionshowForm() { document.getElementById("form1").style.display="block"; returnfalse; } CopySolution 2: If you want the form to submit and are not plann9ing to use AJAX, you need the PHP to do the hiding when reloading the pageBaca JugaCustom File Input Using Jquery Restrict The User File Types And Filename If The User Click Check Box It Input File DisableHow To Pass Url For Dynamically Generated Anchor Tags To Jquery Hover() Function??Converting A Php Array Into Html Form Inputs Is Duplicating Itemsif(isset($_POST['b1'])) { // name of your submit button$hide = true; ?> <input type="button" id="button1 value="click to show form again" /> <? } ?> <form id="form1" class="<?echo$hide?"hidden":"shown";?>"></form> Copyand add$(function() { $("#button1").on("click",function() { $("#form1").prop("class","shown"); }); }); Copyplus a css .hidden { display:none } .shown { display:block } Copy Share You may like these postsBackground/background Image Not Working?How To Loop Multiple Table Th In AngularjsCss3 Media Queries Are Not WorkingUse A Texture And A Color On A Cube Three.js Post a Comment for "Hide Form Using Javascript"
Post a Comment for "Hide Form Using Javascript"