I’m new to javascript, I’ve always just taken free scripts from a variety of sources. This one’s sort of similar except that I took a random title generator script and have edited (or tried to edit) it to my needs.
I have no idea what is wrong and I’m not getting an error message – the random titles just simply aren’t showing up in the text fields when I click ‘Conjure Titles’. I don’t have a debugger or anything that could help me find the problem.
Basically, I can’t pin point what I need help with for you. If you want to see my code not working, go [URL=http://devoted2hp.webspace4free.biz/random.html]here
Here the’s script below, can anyone tell me what’s wrong and how to fix it? I’ve chopped most of the words out of the array sections so the script isn’t that long for you to look at.
[code=php]<HEAD>
<script language=”JavaScript”>
<!–
var noun = new Array(
“Return”,”Legacy”,”Birth”,”Healer”,”Healing”,
“Wand”,”Spell”,”Full Body Bind”,”Jelly Legs Jinx”,
“Bat Bogey Curse”,”Common Room”,”Secret Passage”,”Decedant”
)
var name = new Array(
“Black”,”Malfoy”,”Buckbeak”,”Mrs Norris”,
“Lovegood”,”Luna”,”Cedric”,”Hufflepuff”,
“Cornelius”,”Ginny”,”Fred”,”Peter”,
“George”,”Molly”,”Doris Crockford”,”Potter”,
“Colin Creevey”,”Avery”,”Mr Ollivander”,”Bill”,
“Pig”,”Hermes”,”Phineas”,”Mrs Black”,
“Dobby”,”Winky”,”House Elf”,”Firenze”
)
var adjective = new Array(
“Metallic”,”Marble”,”Stony”,”Rocky”,”Great”,”Royal”,
“Noble”,”Wet”,”Dry”,”Bleeding”,”Piercing”,”Singing”,
“Dancing”,”Painful”,”Wandering”,”Loyal”,”Trusting”,
“Open”,”Closed”,”Locked”,”Free”,”Chained”,”Caged”,
“Empty”,”Wilted”,”Lunar”,”Solar”,”Screaming”,”Dead”,
“Shaking”,”Thrusting”,”Frantic”
)
var a = 0;
var b = 0;
var c = 0;
function RandomTitle(nameform) {
a = Math.floor(Math.random() * noun.length);
b = Math.floor(Math.random() * adjective.length);
c = Math.floor(Math.random() * name.length);
nameform.first.value=name[c] + “‘s ” + adjective[b] + ” ” + noun[a];
}
var d = 0;
var e = 0;
function RandomTitle2(nameform) {
d = Math.floor(Math.random() * adjective.length);
e = Math.floor(Math.random() * noun.length);
nameform.second.value=”The ” + adjective[d] + ” ” + noun[e];
}
var f = 0;
var g = 0;
function RandomTitle3(nameform) {
f = Math.floor(Math.random() * noun.length);
g = Math.floor(Math.random() * noun.length);
nameform.third.value=noun[f] + ” of ” + noun[g] ;
}
var h = 0;
var i = 0;
function RandomTitle4(nameform) {
h = Math.floor(Math.random() * noun.length);
i = Math.floor(Math.random() * name.length);
nameform.fourth.value=”The ” + noun[h] + “of ” + name[i];
}
var j = 0;
var k = 0;
function RandomTitle5(nameform) {
j = Math.floor(Math.random() * noun.length);
k = Math.floor(Math.random() * noun.length);
nameform.fifth.value=”Harry Potter and the ” + noun[j] + ” of the ” + noun[k];
}
var l = 0;
var m = 0;
var n = 0;
function RandomTitle6(nameform) {
l = Math.floor(Math.random() * noun.length);
m = Math.floor(Math.random() * noun.length);
n = Math.floor(Math.random() * name.length);
nameform.sixth.value=name[n] and the ” + noun[l] + ” of the ” + noun[m];
}
//–>
</script>
</HEAD>
<BODY>
<center>
<form>
<table width=400>
<tr>
<td align=center colspan=2>
<input type=button name=generate value=”Conjure Titles!” onClick=”RandomTitle(this.form);
RandomTitle2(this.form);RandomTitle3(this.form);RandomTitle4(this.form);RandomTitle5(this.form);RandomTitle6(this.form)”>
</td>
</tr>
<tr>
<td align=center><b>Title 1:</b></td>
<td align=center><input type=text name=first size=35
style=”background:white”></td>
</tr>
<tr>
<td align=center><b>Title 2:</b></td>
<td align=center><input type=text name=second size=35
style=”background:white”></td>
</tr>
<tr>
<td align=center><b>Title 3:</b></td>
<td align=center><input type=text name=third size=35
style=”background:white”></td>
</tr>
<tr>
<td align=center><b>Title 4:</b></td>
<td align=center><input type=text name=fourth size=35
style=”background:white”></td>
</tr>
<tr>
<td align=center><b>Title 5:</b></td>
<td align=center><input type=text name=fifth size=35
style=”background:white”></td>
</tr>
<tr>
<td align=center><b>Title 6:</b></td>
<td align=center><input type=text name=sixth size=35
style=”background:white”></td>
</tr>
</table>
</form>
</center>
</body>