I am trying to make two forms that do not display at the same time. The first remains visible when the page opens, but if the user selects, the first should be hidden, and the second should take the place. So here is my CSS for this:
#switcher { float: right; font-size: 12px; } #web_upload { visibility: hidden; } #local_upload { visibility: visible; }
Here is the HTML:
<form action="img_upload.php" id="local_upload" method="post" enctype="multipart/form-data"> <center> <input type="file" name="file" id="file" /> <br /> <input type="image" name="submit" src="graphics/upload.png" /> </center> </form> <form action="url_upload.php" id="web_upload" method="post" method="post"> <center> <input type="text" name="url" id="url" /> <br /> <input type="image" name="submit" src="graphics/upload.png" /> </center> </form>
And here is my Javascript:
function showHide(id, other) { if(document.getElementById(id)) { if(document.getElementById(id).style.visibility != "hidden") { document.getElementById(other).style.visibility = "hidden"; document.getElementById(id).style.visibility = "visible"; } else { document.getElementById(id).style.visibility = "hidden"; document.getElementById(other).style.visibility = "visible"; } } }
So I have three problems:
- The second form has a reserved space on the page, and I do not want this empty space.
- The second form is displayed on this reserved place instead of going through the first.
- If the user selects one of the options and tries to select the other after nothing happens
How can I solve these problems?
source share