Hide one form when other button is clicked on (two buttons, two forms) (PHP/HTML/Javascript) -


i have 2 buttons, each displays different form. have buttons when click on once, it'll show form, , if click on again, it'll hide form.

what want do: i'm trying if 1 form shown , click on button other form, 1 showing hide , other 1 show.

here's thought work, if 1 of form shown , click on button other form, nothing happens.

<script>      function show(x, y){          if(document.getelementbyid(x).style.display == "none" && document.getelementbyid(y).style.display != "none"){              document.getelementbyid(x).style.display == "block";              document.getelementbyid(y).style.display == "none";          }          else if(document.getelementbyid(x).style.display == "none") {              document.getelementbyid(x).style.display = "block";          }          else{              document.getelementbyid(x).style.display = "none";          }      }  </script>    <form>      <button type = "button" onclick = 'show("searchform", "insertform");'>perform search</button>      <button type = "button" onclick = 'show("insertform", "searchform");'>insert data</button>  </form>        <form id = "searchform" value "search" style = "display: none;" action = "test2.php" method = "post">        <!-- code -->      </form>    <form id = "insertform" style = "display: none;" action = "test2.php" method = "post">          <!-- code -->          </form>	

i'm sure it's silly mistake i'm making. can me figure out , explain i'm doing wrong , should doing instead? thanks!

you doing comparisons == in if, , need use assignment =

if(document.getelementbyid(x).style.display == "none" && document.getelementbyid(y).style.display != "none"){     document.getelementbyid(x).style.display = "block";                                              ^     document.getelementbyid(y).style.display = "none";                                              ^ } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -