Click to See Complete Forum and Search --> : Javascript. Button linking to counter... well... it's better to read. :p


MalachiteKismet
03-04-2003, 12:05 AM
Basically, what I'm looking to do is exactly as follows:

Start page: A button, like out of a form. When clicked, it leads to a secondary page.

Secondary page: The button was clicked. The number of times that button has been clicked is shown as a number on this secondary page.

Think of it as a sort of prehistoric guest book. My site also uses frames (just one on the side), but I doubt that will effect the script.

And it may be entirely impossible, but can the script also manage to track who's clicked, so that it can't be registered more than once?

Well, I'll stop rambling now. :p Thanks for anything (and I mean that - ANYTHING) you can give me. Shanti!

'Kismet

Nicodemas
03-04-2003, 04:45 AM
The way you are wanting this set up would not work, only because as soon as the button is clicked, the function to send the users to the following page would fire off, and therefore, your browser will not track, onl y start navigating.
If you had *two* buttons, one for users to click on X number of times, and then one to click on the send them to the next page, that is do-able, but only with cookies or server-side scripting.

For the first button, create a function that will keep track of the number of times clicked.
for example an onClick handler:

<html>
<script language="javascript">
var num =0;
function numtimesclicked(){
num = num+1;
}
function tellme(){
alert(num);
}
</script>
<body>
<input type="button" onClick="numtimesclicked()" value=press>
<input type="button" onClick="tellme()" value=tell me>
</body>
</html>

Make it a form, and when the form is submitted, have it create a cookie who's value is set to the variable "num". Of course, this requires the user be using cookies.

MalachiteKismet
03-10-2003, 04:00 PM
Thanks much for the help! :) I should be able to use the information you've given me.

Nedals
03-10-2003, 05:12 PM
My site also uses frames (just one on the side), but I doubt that will effect the script.No! but it will sure help to do what you want.
Create a variable (noOfClicks) in the static frame. Each time the button is clicked (in the active frame, I assume), run a script to increment 'noOfClicks' before if loads the next page. Now use the value to set the BUTTON value on the new page.

QED. :)