Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 11-19-2011, 06:40 AM   #1
Join Date: Jan 2011
Posts: 57
Default showHide two divs with js?

I have a submit-button: When clicked after validation i want the div containing button to hide and at the same time a new div to appear.

With this code i can make the div with button disappear, but i cant get the hidden div to show up instead.

Where am i going wrong? Im not too familiar with js..

<!--script to close-button-->
<script type="text/javascript" >
function showHide(elementid){
if (document.getElementById(elementid).style.display == 'none'){
document.getElementById(elementid).style.display = '';
} else {
document.getElementById(elementid).style.display = 'none';

<!--NOT WORKING script that should open-div-->
function showhide(elementid){
if (document.getElementById(elementid).style.display == 'block'){
document.getElementById(elementid).style.display = 'none';
document.getElementById(elementid).style.display = 'block';

#info-visible {
position: absolute;
z-index: 1000;
left: 200px;
top: 100px;
width: auto;
height: auto;
border: 2px solid #888;
background: #000099;
#target {
display: none;
position: absolute;
z-index: 1000;
left: 500px;
top: 100px;
width: 400px;
height: 400px;
border: 2px solid #888;
background: #009900;

<div id="info-visible" >
<p>visible div</p>
<FORM NAME="submission" onSubmit="return myfunction()" action="javascript:showHide('info-visible'); showHide('target')" >
<INPUT NAME="textfield" TYPE="TEXT">

<div id="target"><p>hidden div</p></div>
henryhayes is offline   Reply With Quote
Old 11-20-2011, 06:32 AM   #2
Join Date: Dec 2004
Posts: 405


Key is to set the display to block for info-visible before it can be set to none
ranjan is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 05:44 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com