here’s my ultimate goal:
random band name generator!– the visitor picks 3 numbers 1-100 or clicks random to have them picked for him and then the three numbers refer to three seperate lists of 100 words to produce the result of an nearly endless possible outcomes of unique phrases
here’s my problem:
I can’t figure out how to get the values of the three number boxes to update the numbers for the varibles of the three lists. actually i can’t get the values of the three number boxes to do much of anything.
This is my first attempt at doing anything with javascript, and I don’t really know what I’m doing, but here’s what I’ve tried so far:
first of all, I haven’t actually gotten to the afformentioned lists of awesome words yet. I’ve just been trying to get the values of the three boxes to affect the text at all. my most recent failed attempt was
[code=php]<head>
<script language=”javascript”>
function Process1() {
var str=document.getElementById(‘list1’).value;
document.getElementById(‘word1’).innerHTML=str;
}
function Process2() {
var str=document.getElementById(‘list2’).value;
document.getElementById(‘word2’).innerHTML=str;
}
function Process3() {
var str=document.getElementById(‘list3’).value;
document.getElementById(‘word3’).innerHTML=str;
}
</script></head>
<p>
<form name=form>
<label for=”list1″><input type=text name=text1 id=”text1″ size=3 maxlength=3></label>
<label for=”list2″><input type=text name=text2 id=”text2″ size=3 maxlength=3></label>
<label for=”list3″><input type=text name=text3 id=”text3″ size=3 maxlength=3></label><br>
<input type=button value=”roll the dice” name=button onclick=”random1(numb1, dice1); random2(numb2, dice2); random3(numb3,
dice3)”><input type=button value=”generate” onclick=”Process1(); Process2(); Process3()”>
</form>
</p>
<p id=”word1″>first word</p>
<p id=”word2″>second word</p>
<p id=”word3″>third word</p>
i also tried a function that was something to the efect of
if document.form.text1.value=1
document.write(“word1”)
else if document.form.text1.value=2
document.write(“word2”)
etc, etc,
…but that wasn’t doing anything
it seems like it should be a pretty basic function, but I just can’t seem to figure it out. can someone give me a push in the right direction?
here’s the whole thing in case anyone cares
[code=php]<html>
<head>
<script language=”javascript”>
<!–
var numb1 = 100;
var numb2 = 100;
var numb3 = 100;
var dice1 = 1;
var dice2 = 1;
var dice3 = 1;
function random1 (numb1, dice1) {
var roll1 = 0;
for (loop=0; loop < dice1; loop++) {
roll1 = roll1 + Math.round(Math.random() * numb1) % numb1 + 1;
}
document.form.text1.value = roll1;
}
function random2 (numb2, dice2) {
var roll2 = 0;
for (loop=0; loop < dice2; loop++) {
roll2 = roll2 + Math.round(Math.random() * numb2) % numb2 + 1;
}
document.form.text2.value = roll2;
}
function random3 (numb3, dice3) {
var roll3 = 0;
for (loop=0; loop < dice3; loop++) {
roll3 = roll3 + Math.round(Math.random() * numb3) % numb3 + 1;
}
document.form.text3.value = roll3;
}
function Process1() {
var str=document.getElementById(‘list1’).value;
document.getElementById(‘word1’).innerHTML=str;
}
function Process2() {
var str=document.getElementById(‘list2’).value;
document.getElementById(‘word2’).innerHTML=str;
}
function Process3() {
var str=document.getElementById(‘list3’).value;
document.getElementById(‘word3’).innerHTML=str;
}
//–>
</script>
</head>
<body bgcolor=”#000000″ text=”#FFFFCC”>
<basefont face=”arial”>
Enter 3 numbers 1-100:<br>
<p>
<form name=form>
<label for=”list1″><input type=text name=text1 id=”text1″ size=3 maxlength=3></label>
<label for=”list2″><input type=text name=text2 id=”text2″ size=3 maxlength=3></label>
<label for=”list3″><input type=text name=text3 id=”text3″ size=3 maxlength=3></label><br>
<input type=button value=”roll the dice” name=button onclick=”random1(numb1, dice1); random2(numb2, dice2); random3(numb3,
dice3)”><input type=button value=”generate” onclick=”Process1(); Process2(); Process3()”>
</form>
</p>
<p id=”word1″>first word</p>
<p id=”word2″>second word</p>
<p id=”word3″>third word</p>
</body>
</html>