The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Random number generator
Oops!
post Jan 16 2012, 01:12 PM
Post #1





Group: Members
Posts: 2
Joined: 16-January 12
Member No.: 16,267



Hello

I am trying to figure out the best way to go about generating a random number but having that number stored on a separate html page.

I am setting up a forum that allows quest posting but I wish to offer a way for the OP to request thread deletion or an edit, The only way I can see to achieve this would be to generate a random code to be displayed after thread creation (which I have a script for) but I then need to save that code in the thread with a conditional so that only admin and mods can see but I cant seem to figure out how to store the generated number into a separate html page.

If anyone has any ideas it would be much appreciated, below is the script I am currently looking at.


CODE
<script LANGUAGE="JavaScript">
num= new Array(16);
for (i=0; i<16; i++) {
num[i]=Math.floor(16*Math.random()+1);
if (num[1]==num[0]) {
while (num[1]==num[0]) {
num[1]=Math.floor(16*Math.random()+1);
   }
}
if (num[2]==num[1] || num[2]==num[0]) {
while (num[2]==num[1] || num[2]==num[0]) {
num[2]=Math.floor(16*Math.random()+1);
   }
}
if (num[3]==num[2] || num[3]==num[1] || num[3]==num[0]) {
while (num[3]==num[2] || num[3]==num[1] || num[3]==num[0]) {
num[3]=Math.floor(16*Math.random()+1);
   }
}
document.write(num[i],"");
}
</SCRIPT>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 16 2012, 01:16 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



You can't do things like that with JavaScript as it only exists in the browser, i.e. it can't write to files on the server.

Doesn't your forum require login? In that case it should be enough that the member who asks for deletion is the same as started the thread.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Oops!
post Jan 16 2012, 01:36 PM
Post #3





Group: Members
Posts: 2
Joined: 16-January 12
Member No.: 16,267



Thanks, I think that saved me some wasted time researching.

To answer your question, No it does not require login so I am seeking a solution for proof of thread ownership for the odd few that request changes or deletion.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
remoteasgiven
post May 11 2012, 10:06 AM
Post #4





Group: Members
Posts: 1
Joined: 11-May 12
Member No.: 17,097



Hi everyone
talking about random numbers,
I would like to show you a true random number generator. http://remoteasgiven.altervista.org/
bye
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 09:54 PM