473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Sorry: its my first script. what is wrong?

Please can you find out what's wrong, fix the script and tell me what was
wrong. Im just beginning
<html>
<head>
<title>Random Mad Lib!</title>
<script language="JavaScript">
<!-- Hide

function displaymadlib(w1, w2, w3, w4, w5, w6, w7, w8, w9, w0, w11, w22, w33,
w44, w55) {

document.writeln("The attack of the purple tissue!!!<br> Once there was
a/an "
+ w1
+ " tissue attacking a "
+ w2
+ " in"
+ w3
+ "! The tissue was even"
+ w4
+ "the"
+ w5
+ "! 4"
+ w6
+ "died of heart attacks. The"
+ w7
+ "was"
+ w8
+ "Suddenly, "
+ 9
+ "man came to"
+ w0
+ "the"
+ w11
+ ". He went up to the tissue and kicked it in the
+ w22
+ ", and the tissue"
+ w33
+ "to the ground. Its snot covered the "
+ w44
+ ", and everything there"
+ w55
+ ".");return true
}

// stop hiding -->

</SCRIPT>

</head>

<body onload="document.madlib.adj1.select()">

<FORM NAME="madlib">
<p>
adjective:
<input name="adj1"></p><br>
<p>
place:
<input name="place1"></p><br>
<p>
another place:
<input name="place2"></p><br>
<p>
verb:
<input name="verb1"></p><br>
<p>
plural noun:
<input name="pnoun1"></p><br>
<p>
another plural noun:
<input name="pnoun2"></p><br>
<p>
place:
<input name="place3"></p><br>
<p>
adjective:
<input name="adj2"></p><br>
<p>
noun:
<input name="noun1"></p><br>
<p>
verb:
<input name="verb2"></p><br>
<p>
noun:
<input name="noun2"></p><br>
<p>
body part:
<input name="bpart"></p><br>
<p>
verb:
<input name="verb3"></p><br>
<p>
place:
<input name="place4"></p><br>
<p>
verb:
<input name="verb4"></p><br>
<p>
<br>
<p>

<INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
OnClick="displaymadlib(document.madlib.adj1.value,
document.madlib.place1.value, document.madlib.place2.value,
document.madlib.verb1.value, document.madlib.pnoun1.value,
document.madlib.pnoun2.value, document.madlib.place3.value,
document.madlib.adj2.value, document.madlib.noun1.value,
document.madlib.verb2.value, document.madlib.noun2.value,
document.madlib.bpart.value, document.madlib.verb3.value,
document.madlib.place4.value, document.madlib.verb4.value)">

<INPUT TYPE="reset" VALUE="reset">

</form>
</body>

</html>
Jul 23 '05 #1
6 2008
You just gotta check every line, coz its small mistakes like not closing a
line with " etc...
======================
<html>
<head>
<title>Random Mad Lib!</title>
<script language="JavaScript">
<!-- Hide

function displaymadlib() {
w1 = document.madlib.adj1.value
w2 = document.madlib.place1.value,
w3 = document.madlib.place2.value
w4 = document.madlib.verb1.value
w5 = document.madlib.pnoun1.value
w6 = document.madlib.pnoun2.value
w7 = document.madlib.place3.value
w8 = document.madlib.adj2.value
w9 = document.madlib.noun1.value
w10 = document.madlib.verb2.value
w11 = document.madlib.noun2.value
w12 = document.madlib.bpart.value
w13 = document.madlib.verb3.value
w14 = document.madlib.place4.value
w15 = document.madlib.verb4.value

document.writeln("The attack of the purple tissue!!!<br> Once there was
a/an "
+ w1
+ " tissue attacking a "
+ w2
+ " in "
+ w3
+ "! The tissue was even "
+ w4
+ "the "
+ w5
+ "! 4 "
+ w6
+ "died of heart attacks. The "
+ w7
+ "was"
+ w8
+ "Suddenly, "
+ w9
+ "man came to"
+ w10
+ "the "
+ w11
+ ". He went up to the tissue and kicked it in the "
+ w12
+ ", and the tissue"
+ w13
+ "to the ground. Its snot covered the "
+ w14
+ ", and everything there "
+ w15
+ ".");return true
}

// stop hiding -->

</SCRIPT>

</head>

<body onload="document.madlib.adj1.select()">

<FORM NAME="madlib">
<p>
adjective:
<input name="adj1"></p><br>
<p>
place:
<input name="place1"></p><br>
<p>
another place:
<input name="place2"></p><br>
<p>
verb:
<input name="verb1"></p><br>
<p>
plural noun:
<input name="pnoun1"></p><br>
<p>
another plural noun:
<input name="pnoun2"></p><br>
<p>
place:
<input name="place3"></p><br>
<p>
adjective:
<input name="adj2"></p><br>
<p>
noun:
<input name="noun1"></p><br>
<p>
verb:
<input name="verb2"></p><br>
<p>
noun:
<input name="noun2"></p><br>
<p>
body part:
<input name="bpart"></p><br>
<p>
verb:
<input name="verb3"></p><br>
<p>
place:
<input name="place4"></p><br>
<p>
verb:
<input name="verb4"></p><br>
<p>
<br>
<p>

<INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
OnClick="displaymadlib()">

<INPUT TYPE="reset" VALUE="reset">

</form>
</body>

</html>
========================
"Rtritell" <rt******@aol.com> wrote in message
news:20***************************@mb-m14.aol.com...
Please can you find out what's wrong, fix the script and tell me what was
wrong. Im just beginning
<html>
<head>
<title>Random Mad Lib!</title>
<script language="JavaScript">
<!-- Hide

function displaymadlib(w1, w2, w3, w4, w5, w6, w7, w8, w9, w0, w11, w22, w33, w44, w55) {

document.writeln("The attack of the purple tissue!!!<br> Once there was a/an "
+ w1
+ " tissue attacking a "
+ w2
+ " in"
+ w3
+ "! The tissue was even"
+ w4
+ "the"
+ w5
+ "! 4"
+ w6
+ "died of heart attacks. The"
+ w7
+ "was"
+ w8
+ "Suddenly, "
+ 9
+ "man came to"
+ w0
+ "the"
+ w11
+ ". He went up to the tissue and kicked it in the
+ w22
+ ", and the tissue"
+ w33
+ "to the ground. Its snot covered the "
+ w44
+ ", and everything there"
+ w55
+ ".");return true
}

// stop hiding -->

</SCRIPT>

</head>

<body onload="document.madlib.adj1.select()">

<FORM NAME="madlib">
<p>
adjective:
<input name="adj1"></p><br>
<p>
place:
<input name="place1"></p><br>
<p>
another place:
<input name="place2"></p><br>
<p>
verb:
<input name="verb1"></p><br>
<p>
plural noun:
<input name="pnoun1"></p><br>
<p>
another plural noun:
<input name="pnoun2"></p><br>
<p>
place:
<input name="place3"></p><br>
<p>
adjective:
<input name="adj2"></p><br>
<p>
noun:
<input name="noun1"></p><br>
<p>
verb:
<input name="verb2"></p><br>
<p>
noun:
<input name="noun2"></p><br>
<p>
body part:
<input name="bpart"></p><br>
<p>
verb:
<input name="verb3"></p><br>
<p>
place:
<input name="place4"></p><br>
<p>
verb:
<input name="verb4"></p><br>
<p>
<br>
<p>

<INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
OnClick="displaymadlib(document.madlib.adj1.value,
document.madlib.place1.value, document.madlib.place2.value,
document.madlib.verb1.value, document.madlib.pnoun1.value,
document.madlib.pnoun2.value, document.madlib.place3.value,
document.madlib.adj2.value, document.madlib.noun1.value,
document.madlib.verb2.value, document.madlib.noun2.value,
document.madlib.bpart.value, document.madlib.verb3.value,
document.madlib.place4.value, document.madlib.verb4.value)">

<INPUT TYPE="reset" VALUE="reset">

</form>
</body>

</html>

Jul 23 '05 #2
On Fri, 7 May 2004 00:14:29 +0200, Dominique <ni****@webadstudio.com>
wrote:

Valid HTML documents should have a document type declaration:

<URL:http://www.w3.org/TR/html4/struct/global.html#h-7.2>
<html>
<head>
<title>Random Mad Lib!</title>
<script language="JavaScript">
This should read

<script type="text/javascript">

The type attribute is required, whereas the language attribute is
deprecated and should no longer be used.
<!-- Hide
The practice of script hiding is now obsolete. Remove the SGML comment
delimiters.
function displaymadlib() {
w1 = document.madlib.adj1.value
w2 = document.madlib.place1.value,
w3 = document.madlib.place2.value
w4 = document.madlib.verb1.value
w5 = document.madlib.pnoun1.value
w6 = document.madlib.pnoun2.value
w7 = document.madlib.place3.value
w8 = document.madlib.adj2.value
w9 = document.madlib.noun1.value
w10 = document.madlib.verb2.value
w11 = document.madlib.noun2.value
w12 = document.madlib.bpart.value
w13 = document.madlib.verb3.value
w14 = document.madlib.place4.value
w15 = document.madlib.verb4.value
Why did you decide to create a series of global variables? Use the var
keyword to keep them local.

By the way, this would be better written as:

function displayMadLib( form ) {
var elems = form.elements;

// Could use an array rather than separate variables
var w1 = elems[ 'adj1' ].value,
w2 = elems[ 'place1' ].value,
w3 = elems[ 'place2' ].value,
w4 = elems[ 'verb1' ].value,
w5 = elems[ 'pnoun1' ].value,
w6 = elems[ 'pnoun2' ].value,
w7 = elems[ 'place3' ].value,
w8 = elems[ 'adj2' ].value,
w9 = elems[ 'noun1' ].value,
w10 = elems[ 'verb2' ].value,
w11 = elems[ 'noun2' ].value,
w12 = elems[ 'bpart' ].value,
w13 = elems[ 'verb3' ].value,
w14 = elems[ 'place4' ].value,
w15 = elems[ 'verb4' ].value;

[snip]
// stop hiding -->
Remove this.

[snip]
<INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
OnClick="displaymadlib()">


This would need to be changed to:

... onclick="displayMadLib(this.form)">

[snipped top-post]

Mike
Please don't top post.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #3
lol@mike

ok... didn't know i was sposed to nail the guy on it... lol*
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:op**************@news-text.blueyonder.co.uk...
On Fri, 7 May 2004 00:14:29 +0200, Dominique <ni****@webadstudio.com>
wrote:

Valid HTML documents should have a document type declaration:

<URL:http://www.w3.org/TR/html4/struct/global.html#h-7.2>
<html>
<head>
<title>Random Mad Lib!</title>
<script language="JavaScript">


This should read

<script type="text/javascript">

The type attribute is required, whereas the language attribute is
deprecated and should no longer be used.
<!-- Hide


The practice of script hiding is now obsolete. Remove the SGML comment
delimiters.
function displaymadlib() {
w1 = document.madlib.adj1.value
w2 = document.madlib.place1.value,
w3 = document.madlib.place2.value
w4 = document.madlib.verb1.value
w5 = document.madlib.pnoun1.value
w6 = document.madlib.pnoun2.value
w7 = document.madlib.place3.value
w8 = document.madlib.adj2.value
w9 = document.madlib.noun1.value
w10 = document.madlib.verb2.value
w11 = document.madlib.noun2.value
w12 = document.madlib.bpart.value
w13 = document.madlib.verb3.value
w14 = document.madlib.place4.value
w15 = document.madlib.verb4.value


Why did you decide to create a series of global variables? Use the var
keyword to keep them local.

By the way, this would be better written as:

function displayMadLib( form ) {
var elems = form.elements;

// Could use an array rather than separate variables
var w1 = elems[ 'adj1' ].value,
w2 = elems[ 'place1' ].value,
w3 = elems[ 'place2' ].value,
w4 = elems[ 'verb1' ].value,
w5 = elems[ 'pnoun1' ].value,
w6 = elems[ 'pnoun2' ].value,
w7 = elems[ 'place3' ].value,
w8 = elems[ 'adj2' ].value,
w9 = elems[ 'noun1' ].value,
w10 = elems[ 'verb2' ].value,
w11 = elems[ 'noun2' ].value,
w12 = elems[ 'bpart' ].value,
w13 = elems[ 'verb3' ].value,
w14 = elems[ 'place4' ].value,
w15 = elems[ 'verb4' ].value;

[snip]
// stop hiding -->


Remove this.

[snip]
<INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
OnClick="displaymadlib()">


This would need to be changed to:

... onclick="displayMadLib(this.form)">

[snipped top-post]

Mike
Please don't top post.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)

Jul 23 '05 #4
Ron
Heya rt,
I'm going at add a little to Mike's reply in the interest of caution
when using document.write and document.writeln. It is
encouraged to use document.open() to let the browser know you're going
to be creating a new document and document.close()
to tell the browser exactly when it can render the new document. My
browser in particular (Mozilla 1.7b) never "finished" loading the page.
Also, it's important to be aware that document.write() writes the entire
document.
In other words, you've left out "<html><head>..." etc. and you just have
a document consisting of "The attack of the purple tissue!...". While many
browsers will default to wrapping and rendering such a document fragment
as HTML, it's good practice to give your new document a definite
document type
node and a definite core structure:

var docHeader = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
// Mike likes HTML4.01, but I prefer introducing the simplicity of XML for new web designers.
docHeader += "<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.1\/\/EN\" \"http:\/\/www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
// Double slashes have to be escaped lest they be mistaken for comments.
docHeader += "<html xmlns=\"http:\/\/www.w3.org/1999/xhtml\" xml:lang=\"en\">";
docHeader += "<head>\n";
docHeader += "<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=iso-8859-1\">\n";
docHeader += "<title>Random Mad Lib - Your Mad Lib!</title>\n";
docHeader += "</head>\n";
docHeader += "<body>\n";
var docFooter = "</body>\n</html>";
// The above two variables are good to keep around if you use document.write/ln a lot.

[snip]

document.open();
document.write(docHeader);
document.writeln("The attack of the purple tissue!!!<br> Once there was a/an "
+ w1
+ " tissue attacking a "
+ w2
+ " in"
+ w3
+ "! The tissue was even"
+ w4
+ "the"
+ w5
+ "! 4"
+ w6
+ "died of heart attacks. The"
+ w7
+ "was"
+ w8
+ "Suddenly, "
+ w9
+ "man came to"
+ w10
+ "the"
+ w11
+ ". He went up to the tissue and kicked it in the"
+ w12
+ ", and the tissue"
+ w13
+ "to the ground. Its snot covered the "
+ w14
+ ", and everything there"
+ w15
+ ".");
document.write(docFooter);
document.close();
Jul 23 '05 #5
Ron wrote:
<snip>
var docHeader = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
// Mike likes HTML4.01, but I prefer introducing the simplicity of
XML for new web designers.

<snip>

That is a strange notion in the context of a post discussing the -
write - method as Mozilla's XHTML DOM does not implement the W3C HTML
DOM HTMLDocument interface on the document object, and as a result does
not implement a - write - method at all. So introducing the new web
designer to XHTML in this context implies abandoning the whole approach
in favour of the namespace versions of the DOM Core Node manipulation
methods, for the replacement of the content.

While I don't agree with the decision not to implement HTMLDocument in
the XHTML DOM on Mozilla, Mozilla is easily the most widely used browser
that provides a scriptable DOM for use with XHTML so its implementation
is significant when considering the subject of scripting XHTML
documents.

Richard.
Jul 23 '05 #6
Ron
Richard Cornford wrote:
[snip]
That is a strange notion in the context of a post discussing the -
write - method as Mozilla's XHTML DOM does not implement the W3C HTML
DOM HTMLDocument interface on the document object, and as a result does
not implement a - write - method at all. So introducing the new web
designer to XHTML in this context implies abandoning the whole approach
in favour of the namespace versions of the DOM Core Node manipulation
methods, for the replacement of the content.

While I don't agree with the decision not to implement HTMLDocument in
the XHTML DOM on Mozilla, Mozilla is easily the most widely used browser
that provides a scriptable DOM for use with XHTML so its implementation
is significant when considering the subject of scripting XHTML
documents.

Richard.

Heya Richard,
Interesting, I never noticed that (I've managed to avoid using
document.write() in any of my projects).
Although it's still listed under the DOM Inspector, I noticed that
trying to use it just returns an internal context error. Many other
DOM2 HTML interfaces are still implemented, though. Where can I see a
specification of Mozilla's XHTML DOM ?
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DonLi | last post by:
Hello, I tested a PHP script with a FORM of 2 element and it delivered the mail but then when I added more FORM elements, it failed to deliver. Following is the content of the PHP script that...
16
by: John | last post by:
Hello. If I want to set up my first database and start using it in Dreamweaver what do I need to do? The book I'm working on has a CD with the database on. It is telling me to put it in the...
9
by: Michael Burtenshaw | last post by:
I would like to make a slide show using random images. The problem is my host is 250.com, and they don't support cgi-programs. Is there another way to accomplish random images?
11
by: sneill | last post by:
I have read a number of posts on the use of eval() in Javascript, and I agree that its use is questionable. But it does beg the following question: "How arbitrary does a string need to be before...
0
by: John Ruiz | last post by:
I hate stupidity. Most of all, my own. Feel free to flame me if you think I need to atone for my wrongs. :) "John Ruiz" <no_email@provided.com> wrote in message news:... PRE-SCRIPT: This...
1
by: Harry | last post by:
Hi, Just seeing if anyone can help me with a problem I am having with drop down lists. - I have a asp:dropdownlist that gets its values from a database. - The user then selects a value then...
17
by: PJ | last post by:
Greetings... I have stumbled upon a small problem. I use Ajax to retrieve part of a page I need to update. I update a DIV element with the HTML contents I get from another page. It works...
7
JodiPhillips
by: JodiPhillips | last post by:
Hi, My first post! I've basically taught myself Access and the little I know about VBA through reading these forums and a couple of books. I'm in the middle of a project at work - to put it...
12
by: Phillip B Oldham | last post by:
I'm keen on learning python, with a heavy lean on doing things the "pythonic" way, so threw the following script together in a few hours as a first-attempt in programming python. I'd like the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.