I'm not sure what search terms to put in to find a sample JavaScript that will give me what I need.
I have a Scrambled word game whereby the ONLY thing that changes with the different games is the link to the JavaScript. I know that I can make a page that has 1 HTML page, and a link to the various JS files, whereby the user can choose which game that want to play, without having 26 separate HTML files. However, I do not know how to research to find a code like this, nor can I figure out how to program this.
HTML page
JS drop down Menu
Wanted Result: JS code grabbed, with HTML page showing whats needed for game to be playable, but access the answers from the JS page.
I know that I have to use an Array, with links to the JS files, and some sort of drop down menu, but I don't know how to get the current HTML file, to show the game but with the JS chosen for playing the game. PS. My JavaScript knowledge is extreme newbie with brain damage. I'm only beginning to understand some JS concepts. Thanks in advance!
The code as it stands is: JavaScript
HTML code
I have a Scrambled word game whereby the ONLY thing that changes with the different games is the link to the JavaScript. I know that I can make a page that has 1 HTML page, and a link to the various JS files, whereby the user can choose which game that want to play, without having 26 separate HTML files. However, I do not know how to research to find a code like this, nor can I figure out how to program this.
HTML page
JS drop down Menu
Wanted Result: JS code grabbed, with HTML page showing whats needed for game to be playable, but access the answers from the JS page.
I know that I have to use an Array, with links to the JS files, and some sort of drop down menu, but I don't know how to get the current HTML file, to show the game but with the JS chosen for playing the game. PS. My JavaScript knowledge is extreme newbie with brain damage. I'm only beginning to understand some JS concepts. Thanks in advance!
The code as it stands is: JavaScript
Code:
var word=new Array("waschbecken","toilette","seife","badewanne","wasserhahn","handtuch","dusche","waschlappen","toilettenpapier","wasser","zahnpasta","zahnbürste");
var letter=new Array();
var rand;
var actual;
window.onload=main;
function main()
{
getRand();
scrambleWord();
creatWord();
}
function scrambleWord()
{
actual=word[rand];
Temp=word[rand].length;
for(var myx=0;myx<Temp+2;myx++)
{
zmyx1=myx-1;
letter[myx]=word[rand].substring(zmyx1,zmyx1-1)
}
letter.sort();
word[rand]="";
for(var myx=0;myx<Temp+2;myx++)
word[rand]+=letter[myx];
}
function getRand()
{
rand=Math.floor(Math.random()*word.length);
}
function creatWord()
{
for(var x=0;x<word[rand].length+2;x++)
{
zmyx1=x-1;
a=document.createElement('a');
a.id="aid"+x;
a.className="scramble";
a.innerHTML=word[rand].substring(zmyx1,zmyx1-1);
a.href="javascript:append('"+x+"');";
document.getElementById('board').appendChild(a);
}
}
function creatWord2(x)
{
zmyx1=x-1;
a=document.createElement('a');
a.id="aid2"+x;
a.className="scramble";
a.innerHTML=word[rand].substring(zmyx1,zmyx1-1);
a.href="javascript:retract('"+x+"');";
document.getElementById('assemble').appendChild(a);
}
function append(zmyx1)
{
document.getElementById('aid'+zmyx1).style.visibility="hidden";
//document.getElementById('assemble').innerHTML+=document.getElementById('aid'+zmyx1).innerHTML;
creatWord2(zmyx1);
}
function retract(zmyx1)
{
document.getElementById('aid'+zmyx1).style.visibility="visible";
elem=document.getElementById('aid2'+zmyx1);
document.getElementById('assemble').removeChild(elem);
}
function showWord()
{
document.getElementById('theWord').innerHTML=actual;
}
HTML code
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> Scrambled Words </title>
<META http-equiv="expires" content="Thur, 1 March 2007 13:00:00 GMT">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css" rel="stylesheet"
href="http://www.globalwritersclub.com/gaming/2/word/scrambled/css/scrambled.css">
<script language="Javascript" src="http://www.globalwritersclub.com/gaming/2/word/scrambled/de/js/1a.js"></script>
<link rel="shortcut icon" href="http://www.globalwritersclub.com/gwc/img/gwcicon.gif">
<style type="text/css">
<!--
body {
text-align:center;
}
a.scramble {
color:#9D23EB;
font-weight:bold;
font-size:30;
position:relative;
}
span#assemble {
font-weight:bold;
font-size:30;
position:relative;
}
span#theWord {
color:#0000ff;
background-color:#000000;
font-weight:bold;
font-size:30;
position:relative;
border:2 inset gray;
}
a:hover {
background-color:#000000;
color:#0000ff;
}
-->
</style>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" summary="HEADER TABLE" width="950px">
<tr>
<td> <br></td>
<td class="logoindxblk">
<p class="plogoindx">
<span class="graphicsp">
<span class="graphics1p"> Scrambled Words </span>
<span class="graphics2p"> Durcheinanderbringen Wörter </span>
</span>
<span class="graphics">
<span class="graphics3p"> Mots Confondants </span>
<span class="graphics4p"> Cмешанным Cлов </span>
</span>
<span class="graphics">
<span class="graphics5p"> Palabras Confusión </span>
<span class="graphics6p"> Verwarrende Woorden </span>
</span>
<span class="graphics">
<span class="graphics7p"> 交絡言葉 </span>
<span class="graphics8p"> Parole di Confondimento </span>
<span class="graphics9p"> Palavras de Confusão </span>
</span></p>
</td>
<td><img src="/gwc/img/clear.gif" alt="" border="0" width="20" height="0"> <br></td>
<!-- GLOBE -->
<td class=logotmp">
<br> <br>
<img src="/gwc/img/100.gif" alt="" border="0" width="100" height="100">
</td>
<td><img src="/gwc/img/clear.gif" alt="" border="0" width="20" height="0"> <br></td>
</tr>
<table border="2" align="center" width="100%" cellpadding="5" border="2">
<tr>
<td class="ctr">
<br />
<span id="board"></span>
<br /><br />
<span id="assemble"></span>
<br />
<br />
<span id="theWord"></span>
<form>
<br />
<input type="button" value="^-^ ?" onclick="showWord();" />
<b style="visibility:hidden">__</b>
<input type="button" value="Start!" onclick="javascript:history.go(0);" />
</form>
</td>
</table>
<!-- **FOOTER** Edited out -->
</body>
</html>
Comment