/ Forside/ Teknologi / Hardware / Pc'er / Spørgsmål
Login
Glemt dit kodeord?
Brugernavn 

Kodeord  


Reklame
Top 10 brugere
Pc'er
#NavnPoint
Klaudi 44251
o.v.n. 40523
refi 29114
Fijala 19253
molokyle 16243
webnoob 13935
peet49 11383
EXTERMINA.. 10755
severino 10622
10  miritdk 9779
tilfældig udvælgelse af tekst
Fra : Desmersnaps
Vist : 492 gange
150 point
Dato : 24-03-09 13:28

Hej gruppe
Er der nogen der kender et program, man kan fodre med en masse tekstlinjer (spørgsmål til et spil), og så få en tilfældig linje hver gang man fx trykker på en knap? Altså en eller anden form for random generator?

Mvh Kasper

 
 
Kommentar
Fra : Eyvind


Dato : 24-03-09 13:44

Måske kan du bruge dette spil "hangman"

Indsæt dette i notesblok og gem som hang.htm
Nu kan det køre som en webside og du kan rette og lure koderne af.
Det er et spil som kørte på min hjemmeside, og jeg skiftede ud til danske ord med æøå.

Kode
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Ny side 1</title>
</head>

<body>
<SCRIPT LANGUAGE="javascript">

/*
Script by Mike Mcgrath- http://website.lineone.net/~mike_mcgrath
Featured on JavaScript Kit (http://javascriptkit.com)
For this and over 400+ free scripts, visit http://javascriptkit.com
*/

var alpha=new Array();
var alpha_index=0;

var bravo=new Array();
var bravo_index=0;

var running=0;
var failnum=0;
var advising=0;

function pick()
{
var choice="";
var blank=0;

for (i=0; i<words[index].length; i++)
{
t=0;
for(j=0; j<=alpha_index; j++)
if(words[index].charAt(i)==alpha[j] || words[index].charAt(i)==alpha[j].toLowerCase()) t=1;

if (t) choice+=words[index].charAt(i)+" ";
else
{
choice+="_ ";
blank=1;
}
}

document.f.word.value=choice;

if (!blank)
{
document.f.tried.value=" === You Win! ===";
document.f.score.value++;
running=0;
}
}


function new_word(form)
{
if(!running)
{
running=1;
failnum=0;
form.lives.value=failnum;
form.tried.value="";
form.word.value="";
index=Math.round(Math.random()*10000) % 100;
alpha[0]=words[index].charAt(0);
alpha[1]=words[index].charAt(words[index].length-1);
alpha_index=1;
bravo[0]=words[index].charAt(0);
bravo[1]=words[index].charAt(words[index].length-1);
bravo_index=1;
pick();
}
else advise("A word is already in play!");
}

function seek(letter)
{
if (!running) advise(".....Click GO to start !");
else
{
t=0;
for (i=0; i<=bravo_index; i++)
{
if (bravo[i]==letter || bravo[i]==letter.toLowerCase()) t=1;
}

if (!t)
    {
    document.f.tried.value+=letter+" "
    bravo_index++;
    bravo[bravo_index]=letter;
   
for(i=0;i<words[index].length;i++)
    if(words[index].charAt(i)==letter || words[index].charAt(i)==letter.toLowerCase()) t=1;
   
if(t)
{
    alpha_index++;
    alpha[alpha_index]=letter;
    }
    else failnum++;
   
document.f.lives.value=failnum;
    if (failnum==6)
{
document.f.tried.value="You lose - Try again!";
document.f.word.value=words[index];
document.f.score.value--;
running=0;
}
         else pick();
    }
    else advise("Letter "+letter+" is already used!");
}
}

function advise(msg)
{
if (!advising)
{
advising=-1;
savetext=document.f.tried.value;
document.f.tried.value=msg;
window.setTimeout("document.f.tried.value=savetext; advising=0;",1000);
}
}

var words = new Array("","hypocritical","mollycoddle","nimbleness","nonplussed","obliterate","obsequious","obstreperous","opalescent","ostensible","pandemonium","paraphernalia","pawnbroker","pedestrian","peremptory","perfunctory","pernicious","perpetrate","personable","pickpocket","poltergeist","precipitous","predicament","preposterous","presumptuous","prevaricate","propensity","provisional","pugnacious","ramshackle","rattlesnake","reciprocate","recrimination","redoubtable","relinquish","remonstrate","repository","reprehensible","resolution","resplendent","restitution","retaliation","retribution","saccharine","salubrious","skulduggery","skyscraper","soothsayer","tearjerker","transcribe","turpentine","unassuming","underscore","undertaker","underwrite","unobtrusive","vernacular","waterfront","watertight");

</SCRIPT>


<FORM NAME="f">

<TABLE BGCOLOR=#C0C0C0 BORDER=1>
<TR>
<TD COLSPAN=4 ALIGN=RIGHT>
Score : <INPUT TYPE=TEXT NAME="score" VALUE="0" onfocus="score.blur();" SIZE=2>
<BR>
Fails (6): <INPUT TYPE=TEXT NAME="lives" VALUE="0" onfocus="lives.blur();" SIZE=2>
</TD>
<TD COLSPAN=7 ALIGN=CENTER>
<INPUT TYPE=TEXT NAME="word" VALUE=" --- Hangman ---" onfocus="word.blur();" SIZE=25>
<BR>
<INPUT TYPE=TEXT NAME="tried" VALUE="Click GO to get a word." onfocus="tried.blur();" SIZE=25>
</TD>
<TD COLSPAN=2 ALIGN=CENTER>
<INPUT TYPE=BUTTON onclick="new_word(this.form);" VALUE=" GO ">
</TD>
</TR>
<TR>
<TD><INPUT TYPE=BUTTON VALUE=" A " onclick="seek('A');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" B " onclick="seek('B');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" C " onclick="seek('C');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" D " onclick="seek('D');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" E " onclick="seek('E');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" F " onclick="seek('F');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" G " onclick="seek('G');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" H " onclick="seek('H');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" I " onclick="seek('I');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" J " onclick="seek('J');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" K " onclick="seek('K');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" L " onclick="seek('L');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" M " onclick="seek('M');"></TD>
</TR>
<TR>
<TD><INPUT TYPE=BUTTON VALUE=" N " onclick="seek('N');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" O " onclick="seek('O');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" P " onclick="seek('P');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" Q " onclick="seek('Q');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" R " onclick="seek('R');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" S " onclick="seek('S');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" T " onclick="seek('T');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" U " onclick="seek('U');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" V " onclick="seek('V');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" W " onclick="seek('W');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" X " onclick="seek('X');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" Y " onclick="seek('Y');"></TD>
<TD><INPUT TYPE=BUTTON VALUE=" Z " onclick="seek('Z');"></TD>
</TR>
</TABLE>

</FORM>

<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p>
</body>

</html>


Kommentar
Fra : molokyle


Dato : 24-03-09 14:17

En passwordgenerator?

http://www.pctools.com/guides/password/

</MOLOKYLE>

Kommentar
Fra : molokyle


Dato : 24-03-09 14:18

Ups... misforstod

</MOLOKYLE>

Kommentar
Fra : Desmersnaps


Dato : 24-03-09 14:32

@ Eyvind

Synes nu det ligger lidt langt fra. Skal jo bruge hele spørgsmål, ikke bare enkelte ord. Og her skal man gætte hvordan de staves. Jeg leder bare efter en maskine der vælger et tilfældigt spørgsmål, og når man trykker igen kommer et andet spørgsmål frem.... Men tak for forsøget



Kommentar
Fra : Eyvind


Dato : 24-03-09 14:44

Jeg tænkte nu om du kunne hente den tilfældige udvælgelse ud af programmet.

Accepteret svar
Fra : Klaudi

Modtaget 150 point
Dato : 24-03-09 15:03

Her er et, kan det bruges?

<form name="random"><input type="text" name="random" size=78 value=""></form>

<SCRIPT LANGUAGE="JavaScript">
<!--
function getMessage() {
// create array of murphy laws
var ar = new Array(20)
ar[0] = "Nothing is as easy as it looks."
ar[1] = "Everything takes longer than you think."
ar[2] = "Anything that can go wrong will go wrong."
ar[3] = "If there is a possibility of several things going wrong, the one that will cause the most damage will be the one to go wrong."
ar[4] = "If there is a worse time for something to go wrong, it will happen then."
ar[5] = "If anything simply cannot go wrong, it will anyway."
ar[6] = "If you perceive that there are four possible ways in which a procedure can go wrong, and circumvent these, then a fifth way, unprepared for, will promptly develop."
ar[7] = "Left to themselves, things tend to go from bad to worse."
ar[8] = "If everything seems to be going well, you have obviously overlooked something."
ar[9] = "Nature always sides with the hidden flaw."
ar[10] = "Mother nature is a bitch."
ar[11] = "It is impossible to make anything foolproof because fools are so ingenious."
ar[12] = "Whenever you set out to do something, something else must be done first."
ar[13] = "Every solution breeds new problems."
ar[14] = "Trust everybody ... then cut the cards."
ar[15] = "Two wrongs are only the beginning."
ar[16] = "If at first you don't succeed, destroy all evidence that you tried."
ar[17] = "To succeed in politics, it is often necessary to rise above your principles."
ar[18] = "Exceptions prove the rule ... and wreck the budget."
ar[19] = "Success always occurs in private, and failure in full view."

var now = new Date()
var sec = now.getSeconds()
document.random.random.value="Murphy's Law: " + ar[sec % 20]
}
getMessage()
//-->
</SCRIPT>

mvh klaudi

Kommentar
Fra : Klaudi


Dato : 24-03-09 15:25

En mere:

<script language="JavaScript">
// ==============================================
// Copyright 2004 by CodeLifter.com
// Free for all; but please leave in this header.
// ==============================================

var Quotation=new Array() // do not change this!

// Set up the quotations to be shown, below.
// To add more quotations, continue with the
// pattern, adding to the array. Remember
// to increment the Quotation[x] index!

Quotation[0] = "Time is of the essence! Comb your hair.";
Quotation[1] = "Sanity is a golden apple with no shoelaces.";
Quotation[2] = "Repent! The end is coming, $9.95 at Amazon.";
Quotation[3] = "Honesty blurts where deception sneezes.";
Quotation[4] = "Pastry satisfies where art is unavailable.";
Quotation[5] = "Delete not, lest you, too, be deleted.";
Quotation[6] = "O! Youth! What a pain in the backside.";
Quotation[7] = "Wishes are like goldfish with propellors.";
Quotation[8] = "Love the river's \"beauty\", but live on a hill.";
Quotation[9] = "Invention is the mother of too many useless toys.";

// ======================================
// Do not change anything below this line
// ======================================
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>

mvh klaudi

Godkendelse af svar
Fra : Desmersnaps


Dato : 27-03-09 08:57

Tak for svaret Klaudi. Jeg endte med at bruge dit første forslag. Også tak til alle andre for buddene

Kommentar
Fra : Klaudi


Dato : 27-03-09 09:00

Velbekommen

Du har følgende muligheder
Eftersom du ikke er logget ind i systemet, kan du ikke skrive et indlæg til dette spørgsmål.

Hvis du ikke allerede er registreret, kan du gratis blive medlem, ved at trykke på "Bliv medlem" ude i menuen.
Søg
Reklame
Statistik
Spørgsmål : 173562
Tips : 31660
Nyheder : 719565
Indlæg : 6383040
Brugere : 218252

Månedens bedste
Årets bedste
Sidste års bedste