South Africa’s biggest forum. Discuss, discover, and connect with thousands of members.
'Sent
Sent(0) = "Sentence 1"
Sent(1) = "Sentence 2"
Sent(2) = "Sentence 3"
Sent(3) = "Sentence 4"
'Pick Random Array Offsets
Randomize Timer
SO = Int(UBound(Sent) * Rnd + LBound(Sent))
MsgBox "" & Sent(SO)
Erase Sent
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Random Sentence w/Cookie script - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<span id="theS"></span>
<script type="text/javascript">
/* Random Sentence w/Cookie script
* All credits must remain for legal use */
// Cookie code from: http://www.quirksmode.org/js/cookies.html
function createCookie(name,value) {
document.cookie = name+"="+value+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca;
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function rs(){ // Random Sentence on Refresh w/Cookie - jscheuer1 - http://www.dynamicdrive.com/forums
var s=[
'Hey there',
'How there',
'Hey now',
'Way home',
'All now'];
s.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter)
var sn=readCookie('sen')&&readCookie('sen')==s[0]? s[1] : s[0];
document.getElementById('theS').innerHTML=sn;
createCookie('sen',sn)
}
rs();
</script>
</body>
</html>
You do realise it would have been a lot easier if you put them in a mysql database and just called the rand query and it would have randomly called you a row out the db. less lines than the javascript.
I hate javascript. Infact i hate anything that requires the client to have support for. Server side is much better.![]()
indeed. I also despise asp.net cos it seems to rely heavily on javascript to get anything done. Ms need to pull up their socks with that. To each his own i suppose
Again you are very wrong. ASP.NET is very powerful and scalable, especially if you know what you are doing. Forget about just using web forms. The true power of .NET lies in its ability to build scalable multi-tier applications. XML and XSLT give you a powerful alternative to "hard coding" web forms and the new ASP.NET MVC framework also opens up the possibilities of discarding traditional web forms.just not for web.
lol. we could be here all day.
i suggest
GetRoom(FarligOpptreden,monkeeh);
![]()
Participants theParticipants = new Participants();
theParticipants.Add(new Participant("FarligOpptreden",26932));
theParticipants.Add(new Participant("monkeeh",7543));
GetRoom(theParticipants);
roflYour implementation is limited in the sense that it implies that only 2 participants can be in a room at any point in time. A better solution would be to define the method to accept a collection / array of Participants, which would make for a more flexible and scalable implementation.
So you could define a Participant object with properties for Id and Name, as well as a collection of Participants (making sure to implement the IEnumerable interface, of course) and implement the solution as follows:
Code:Participants theParticipants = new Participants(); theParticipants.Add(new Participant("FarligOpptreden",26932)); theParticipants.Add(new Participant("monkeeh",7543)); GetRoom(theParticipants);
Another thing, what is the return value of your method GetRoom()? Is it just void? And what happens to the participants afterwards? Or should they be passed in by reference? So many questions...
Nonsense. If the return type for the method is void and the objects aren't passed by reference, they'll know they are going into a void and won't be returning. Well, I'm speaking for myself, of course. Apparently monkeeh isn't too acquainted with .NET, so he might end up stuck in the void...they stay in the void, but they don't know that beforehand
![]()