Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    button that creates scroll box

    I was curious if anyone could show me how to create a button that will run a certain script ie: press button named "reveal" -> scroll box is created with other buttons inside it that do other functions.

    all help is appreciated I ave no idea how to go about doing this

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,458
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    What is a "scroll box"?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    a division of space designated by height and width.... I just answered my own stupid question didn't I?....
    -edit-
    actually hold on I didn't I need to know how to make a button create said space

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,458
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    Well, the easiest way is to *NOT* "create" the box.

    Instead, just have it hidden when the page appears
    Code:
    <div id="myBox" style="display: none;">
        .... any content you want, including buttons ...
    </div>
    And then just have your button make it appear:
    Code:
    <input type="button" value="show the box"
           onclick="document.getElementById('myBox').style.display='block';" />
    BUt I was really curious if you meant a box so big that it needed to be scrollable.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    the6ness (09-29-2011)

  • #5
    New Coder
    Join Date
    Sep 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    also, its off topic but can you show me how to create a pop up when you attempt to leave the page
    I've tried the window.onunload but I cant seem to get it to work

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,458
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    Almost every popup blocker out there will prevent a popup caused by window.onunload.

    I would not be at all surprised if your code for doing so is correct but your own popup blocker prevents it.

    But show your code, just in case.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    maybe you are talking about window.onbeforeunload? From what I can tell, window.onunload is too late to cancel the action:

    Code:
    function goodbye(e) {
    	if(!e) e = window.event;
    	e.cancelBubble = true;
    	e.returnValue = 'You sure you want to leave?';
    
    	if (e.stopPropagation) {
    		e.stopPropagation();
    		e.preventDefault();
    	}
    }
    
    window.onbeforeunload=goodbye;

  • #8
    New Coder
    Join Date
    Sep 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I actually went a completely different direction with what i was trying to do instead I got a pop up to activate when the function was used 21 times
    thank you foir your feedback though guys

  • #9
    New Coder
    Join Date
    Sep 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ugh I take that back entirely, I can't even figure out the way to make it count the use of a say a button click as soon as it hits <2
    example:
    entering an incorrect password 3 times it will notify you that you have done so and boot you off of the site

  • #10
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,992
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    I am not at all clear what you are trying to do but:-

    Code:
    <form>
    ENTER PASSWORD <input type = "text" name = "pwd" onblur = "checkit()">
    </form>
    
    <script type = "text/javascript">
    
    var count = 0;
    function checkit() {
    var p = document.forms[0].pwd.value;
    if (p == "mypassword") {
    alert ("Correct password")
    // password is OK - proceed
    }
    
    if (count >=2) {
    alert ("Three wrong tries!")
    window.location = "http://www.google.com";
    return false;
    }
    
    if (p!= "mypassword") {
    alert ("Incorrect password - try again!");
    document.forms[0].pwd.value= "";
    count++;
    }
    
    }
    
    </script>
    Note that this is hopelessly insecure as the user can see the correct password simply with View Source.


    "Seize the day, put no trust in the morrow!" [Carpe diem, quam minimum credula postero.] - Horace - Roman lyric poet & satirist (65 BC - 8 BC)

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,458
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    Since password validation should be done server-side, the server-side code (PHP/ASP/JSP) should do the counting. So it should have nothing to do with JavaScript.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #12
    New Coder
    Join Date
    Sep 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I realized that as I was laying down that was a HORRIBLE example
    simply put I want a window to pop up after a button is pressed 20 times


  •  

    Posting Permissions

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