...

View Full Version : button that creates scroll box



the6ness
09-29-2011, 02:17 AM
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

Old Pedant
09-29-2011, 02:23 AM
What is a "scroll box"?

the6ness
09-29-2011, 02:32 AM
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

Old Pedant
09-29-2011, 02:37 AM
Well, the easiest way is to *NOT* "create" the box.

Instead, just have it hidden when the page appears

<div id="myBox" style="display: none;">
.... any content you want, including buttons ...
</div>

And then just have your button make it appear:


<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.

the6ness
09-29-2011, 02:41 AM
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

Old Pedant
09-29-2011, 06:10 AM
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.

xelawho
09-29-2011, 07:43 AM
maybe you are talking about window.onbeforeunload? From what I can tell, window.onunload is too late to cancel the action:



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;

the6ness
09-29-2011, 08:50 AM
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

the6ness
09-29-2011, 09:07 AM
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

Philip M
09-29-2011, 09:30 AM
I am not at all clear what you are trying to do but:-


<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)

Old Pedant
09-29-2011, 10:01 PM
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.

the6ness
09-30-2011, 10:06 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum