www.webdeveloper.com
Results 1 to 2 of 2

Thread: Div disappearing

  1. #1
    Join Date
    Jun 2010
    Posts
    62

    Div disappearing

    Hi



    I have a text box field:



    <form id="form1" name="form1" method="post" action="">
    <span id="sprytextfield1">
    <label for="calc2"></label>
    <input type="text" name="calc2" id="calc2" onchange="checkCalc()"/>
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    </form>



    when user types in correct answer and hits return key, it calls a function:



    <script type="text/javascript">



    function checkCalc(){
    if (document.form1.calc2.value == "1"){
    MM_showHideLayers('pop1','','show','pop2','','hide');
    }
    else { alert("you are incorrect!");
    }
    }
    </script>



    The popup window appears but only for a second and then it disappears





    I use the same MM_showHideLayers('pop1','','show','pop2','','hide') function elsewhere and the pop up remains open

    The pop up is an ap div, with default setting set to hidden. The function then shows the layer, by setting the visability to 'show'



    <p>Velit esse cillum dolore quis nostrud exercitation consectetur <span class="hyperlink" onmousedown="MM_showHideLayers('pop1','','show','pop2','','hide')" onmouseup="MM_effectHighlight('pop1 content', 1000, '#FFFFFF', '#EAEAEA', '#FFFFFF', false)">adipisicing</span> elit. In reprehenderit in voluptate lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt. Ut labore et dolore magna aliqua.</p>

    I use Dreamweaver CS4

    Thanks

    Jon

  2. #2
    Join Date
    Oct 2006
    Posts
    939
    When you hit the Enter button, you are submitting the form.
    Your form tag needs onsubmit="checkCalc()"

    and, the last line of the function needs a return false to prevent the form from doing the submit action.

    Or, you can leave the function as is and append the return false after the function call-

    onsubmit="checkCalc();return false"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles