randomizer component

  • Thread starter Anthony Blackburn
  • Start date
A

Anthony Blackburn

Does anyone know of a component, in which one would press a button on apage
and it will return a random answer from a database?
 
S

Stefan B Rusynko

Use the Randomize and Rnd function in ASP to get a record ID for say 100 records

<%
Randomize
RecordID = Int((100 * Rnd) + 1)
' Use RecordID in your query string to select the record ID
%>
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Does anyone know of a component, in which one would press a button on apage
| and it will return a random answer from a database?
 
P

Peter R. Fletcher

Javascript's Math.Random () function will give you a random number
between 0 and 1, which you can manipulate and use to return random
data from a database with a linear numeric key field.


Does anyone know of a component, in which one would press a button on apage
and it will return a random answer from a database?

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
P

Peter R. Fletcher

ASP is indeed likely to be easier on a MS host - Javascript (see my
other post) should work on any host at the cost of a bit more coding.

Use the Randomize and Rnd function in ASP to get a record ID for say 100 records

<%
Randomize
RecordID = Int((100 * Rnd) + 1)
' Use RecordID in your query string to select the record ID
%>

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
S

Stefan B Rusynko

Problem w/ any client side script is the page has already been rendered
- so it is too late to go back to the server for a DB connection/recordset
If the OP is using a DB, it needs to be done w/ server side script
(if not w/ ASP then probably w/ PHP for non-MS server/DB like MySQL)

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| ASP is indeed likely to be easier on a MS host - Javascript (see my
| other post) should work on any host at the cost of a bit more coding.
|
| On Thu, 6 Jul 2006 04:24:30 -0400, "Stefan B Rusynko"
|
| >Use the Randomize and Rnd function in ASP to get a record ID for say 100 records
| >
| ><%
| >Randomize
| >RecordID = Int((100 * Rnd) + 1)
| >' Use RecordID in your query string to select the record ID
| >%>
|
| Please respond to the Newsgroup, so that others may benefit from the exchange.
| Peter R. Fletcher
 
P

Peter R. Fletcher

You're right, of course - there are ways round that, but none of them
are particularly easy or "clean". PHP would be the way to go for a
non-MS environment.

Problem w/ any client side script is the page has already been rendered
- so it is too late to go back to the server for a DB connection/recordset
If the OP is using a DB, it needs to be done w/ server side script
(if not w/ ASP then probably w/ PHP for non-MS server/DB like MySQL)

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
A

Anthony Blackburn

Your responses are most appreciated, no matter how much over my head they
are......;)

Here's what I am trying to do.

Specifically, one would go to my website with a handheld device and select a
button. Probably one of about 6 or so different choices.

A database linked to that particular button that is pushed would be queried
and display a random result in text (Which is simply a name).

Thanks again
 
S

Stefan B Rusynko

If using ASP the technique at below can be modified
http://www.asp101.com/samples/random_image.asp

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Your responses are most appreciated, no matter how much over my head they
| are......;)
|
| Here's what I am trying to do.
|
| Specifically, one would go to my website with a handheld device and select a
| button. Probably one of about 6 or so different choices.
|
| A database linked to that particular button that is pushed would be queried
| and display a random result in text (Which is simply a name).
|
| Thanks again
|
| "Peter R. Fletcher" wrote:
|
| > Javascript's Math.Random () function will give you a random number
| > between 0 and 1, which you can manipulate and use to return random
| > data from a database with a linear numeric key field.
| >
| >
| > On Thu, 6 Jul 2006 00:02:02 -0700, Anthony Blackburn
| >
| > >Does anyone know of a component, in which one would press a button on apage
| > >and it will return a random answer from a database?
| >
| > Please respond to the Newsgroup, so that others may benefit from the exchange.
| > Peter R. Fletcher
| >
 
Top