faith
05-10-2003, 01:41 PM
Hi, Newbie here!
I'm trying to adapt a script that I got from the freeware downloads of this site: Fortune Cookie and Fortune Teller. Basically, randomly "answers" yes or no questions. (Fun stuff!)
But, I can't get it to work. I don't know what I've done wrong. Would someone be so kind as to take a look?
http://wagatail.com/respond.htm
Thank you! I'm learning, but, boy is it frustrating right now!
Faith
:confused:
Try the following
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ask Jemma Now</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!--Web Site: The JavaScript Source -->
<!-- Based on code by Michael Carpenter -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var quotes = new Array(49)//Add your quotes below
quotes[0]="Milkbones first; advise later",
quotes[1]="Deposit five milkbones, please",
quotes[2]="Everything will be clear ... after a milkbone ...",
quotes[3]="Have a snack; first things first.",
quotes[4]="The Wise Jemma says ... Try again!",
quotes[5]="Now that's just silly.",
quotes[6]="Absolutely, undeniably, make-no-mistake-about-it.",
quotes[7]="No, nope, no way, don't even think about it!",
quotes[8]="Sorry, Snack Time!",
quotes[9]="Oh, well, if you really must know: Maybe.",
quotes[10]="I'm offended--go ask the CAT.",
quotes[11]="That's just too big a question; write me a letter.",
quotes[12]="Sorry, Nap Time!",
quotes[13]="There are many answers to that question. Hmmm.",
quotes[14]="Hey, haven't you asked me that already?!",
quotes[15]="Okay, I see it now: WOW, I mean, BOW WOW! YES!",
quotes[16]="My head and my stomach disagree on this one. Ask again.",
quotes[17]="Of course not! Even the Cat knows that!",
quotes[18]="One thing is very clear: I need a snack.",
quotes[19]="My spots tell me this: Go for it!",
quotes[20]="Have a nap first; all will be clear in the morning.",
quotes[21]="Hmmm. That's a tough one: NO!",
quotes[22]="Yum! Your breath smells like dog food!",
quotes[23]="There's a time for everything, and this is the time to wait.",
quotes[24]="Count my spots: that's how many times I say NO!",
quotes[25]="Sadly, I wasn't listening. Try again later.",
quotes[26]="Hey, I recognize you!",
quotes[27]="Well, maybe if you are smart about it.",
quotes[28]="A chicken could answer that one! Hmmm ... chicken ...",
quotes[29]="First throw a ball 10 times for your dog, then ask me.",
quotes[30]="First, go to the Park with your dog, then all will be well.",
quotes[31]="First, scratch your dog's ears, then your fortune will be great.",
quotes[32]="The Wise Jemma says ... YES!",
quotes[33]="The fridge door opened! Sorry, gotta go!",
quotes[34]="There's that pesky mailman trying to leave bills again. Sorry, later!",
quotes[35]="Hug your dog every day and all will be well.",
quotes[36]="Yum! Your breath smells like cheese!",
quotes[37]="Tell that Cat to get off the computer, then ask me.",
quotes[38]="If your Cat says yes, then I say ... YES! Fooled you!",
quotes[39]="My spots tell me: Run away! NO, NO, NO!",
quotes[40]="Does a Dal like firemen? YES!",
quotes[41]="Does a Dal like chasing balls? YES!",
quotes[42]="Does a Dal like snacks? YES!",
quotes[43]="Does a Dal like baths? NO!",
quotes[44]="You need to concentrate more. Ask again.",
quotes[45]="Quit scratching yourself. Ask my later.",
quotes[46]="Hmmm. That's a tough one. Write me a letter instead.",
quotes[47]="Sorry, it's too close to dinnertime. Later!",
quotes[48]="Sorry, I've got to see a man about a horse. NOW.",
quotes[49]="I sense there is much more to discuss. Write me."
function fortune(){
var rand_int=Math.floor(Math.random()*49);//Get a number for picking the quote
document.form2.quotes.value=quotes[rand_int]
//document.all.myspan.innerHTML=(quotes[rand_int]);//Put the quote in the box
}
//End -->
</SCRIPT>
<Body background="images/paw_back.gif" text="#000000" link="#000000" vlink="#000000" alink="#000000"><body background="images/paw_back.gif" text="#000000" link="#000000" vlink="#000000" alink="#000000">
<div align="right">
<form name="form1">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="http://wagatail.com/respond.htm" selected>Instant Advice
from Jemma</option>
<option value="http://wagatail.com/advice.htm">Dear Jemma . . .</option>
<option value="http://wagatail.com">Wag A Tail!</option>
<option value="http://wagatail.com/shop.htm">Shop Wag A Tail!</option>
<option value="http://wagatail.com/burrita.htm">Burrita's Secret Journal</option>
<option value="http://foxandcrow.com">Fox and Crow Ventures Home</option>
<option value="http://foxsongbooks.com">Fox Song Books</option>
<option value="http://creativecrow.com">The Creative Crow</option>
<option value="http://foxandcrow.com/about.htm#contact">Contact Us</option>
<option value="http://faithrichardson.com">About Faith Richardson</option>
</select>
</form>
<h1 align="center"><font face="Arial, Helvetica, sans-serif">Jemma, the Advice
Dalmatian</font></h1>
<h2 align="center"><font size="5" face="Arial, Helvetica, sans-serif"><strong>Instant
Wisdom from "Dear Jemma . . ."</strong></font></h2>
</head>
<body>
<p align="center"> </p>
<p align="left"><strong><font size="4" face="Arial, Helvetica, sans-serif"><a href="http://wagatail.com"><img src="images/Jemma_Animation.gif" alt="Jemma the Advice Dalmatian!" name="jemma" width="288" height="470" hspace="4" vspace="2" border="0" align="left" id="jemma"></a></font></strong></p>
<p align="left"> </p>
<p align="left"> </p>
<p align="left"><strong><font size="4" face="Arial, Helvetica, sans-serif">Instructions:</font></strong></p>
<p align="left"><strong><font size="4" face="Arial, Helvetica, sans-serif">1.
Think Very Hard about your Problem</font></strong></p>
<p align="left"><strong><font size="4" face="Arial, Helvetica, sans-serif">2.
Ask Jemma a Yes or No Question</font></strong></p>
<p align="left"><strong><font size="4" face="Arial, Helvetica, sans-serif">3.
Click the "Ask Jemma!" Bar</font></strong></p>
<p align="left"><strong><font size="4" face="Arial, Helvetica, sans-serif">4.
Read Jemma's Reply</font></strong></p>
<p align="left"><strong><font size="4" face="Arial, Helvetica, sans-serif">5.
Smile!</font></strong></p>
<p align="left"> </p>
<p align="left"> </p>
<p align="left"> </p>
<center>
<form name="form2">
Your question: <input type="text" name="question" size=60><br>
<input type="button" name="ask" value="Ask Jemma!" onClick="fortune()">
Jemma says: <input type="text" name="quotes" size=70></b><br>
<span id="myspan"></span>
</form>
</center>
<p align="center"><p </p>
<p align="center"> </p>
<p align="center"><a href="mailto:jemma@wagatail.com"><img src="images/Jemmasmailcouch.JPG" alt=""Dear Jemma, ..."" name="jemmamail" width="216" height="204" border="2" id="jemmamail"></a></p>
<p align="center"> </p>
<div align="center">
<p><a href="mailto:Jemma@wagatail.com"><font face="Arial, Helvetica, sans-serif"><strong>Email
Jemma! </strong></font></a></p>
<p> </p>
</div>
<blockquote>
<blockquote>
<div align="center">
<p><strong><font color="#000000" face="Arial, Helvetica, sans-serif">
copyright © 2003 Fox and Crow Ventures</font></strong></p>
<p><font color="#000000" face="Arial, Helvetica, sans-serif"><strong>All
Rights Reserved</strong></font></p>
<p><strong><font color="#000000" face="Arial, Helvetica, sans-serif"><a href="http://foxandcrow.com"><img src="images/Crest1.gif" alt="Fox and Crow Ventures" name="crest" width="151" height="120" border="0" id="crest"></a></font></strong></p>
</div>
</blockquote>
</blockquote>
<p align="center"><font face="arial,helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font></center><p>
</p>
</div>
</body>
</html>
faith
05-10-2003, 04:55 PM
Wow, it works!
Thank you so much!
Now, I'm going to pour over the script and figure out what you did differently and learn, learn, learn!
Thank you!
Faith
:D
Hi Faith
There wasn't a great deal wrong with your page.
The main area was that the form "quotes" input box was not referenced.
The other problems were just typos .... I think :)
function fortune(){
var rand_int=Math.floor(Math.random()*49);//Get a number for picking the quote
document.form2.quotes.value=quotes[rand_int]
//document.all.myspan.innerHTML=(quotes[rand_int]);//Put the quote in the box
}
Glad I was able to help :)