473,789 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript">
<!-- Hide

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

document.writel n("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="documen t.madlib.adj1.s elect()">

<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="displa ymadlib(documen t.madlib.adj1.v alue,
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 2026
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="JavaS cript">
<!-- 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.writel n("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="documen t.madlib.adj1.s elect()">

<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="displa ymadlib()">

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

</form>
</body>

</html>
=============== =========
"Rtritell" <rt******@aol.c om> 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="JavaS cript">
<!-- Hide

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

document.writel n("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="documen t.madlib.adj1.s elect()">

<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="displa ymadlib(documen t.madlib.adj1.v alue,
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****@webadst udio.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="JavaS cript">
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="displa ymadlib()">


This would need to be changed to:

... onclick="displa yMadLib(this.fo rm)">

[snipped top-post]

Mike
Please don't top post.

--
Michael Winter
M.******@blueyo nder.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.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
On Fri, 7 May 2004 00:14:29 +0200, Dominique <ni****@webadst udio.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="JavaS cript">


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="displa ymadlib()">


This would need to be changed to:

... onclick="displa yMadLib(this.fo rm)">

[snipped top-post]

Mike
Please don't top post.

--
Michael Winter
M.******@blueyo nder.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.writel n. 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=\"appli cation/xhtml+xml; charset=iso-8859-1\">\n";
docHeader += "<title>Ran dom 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.writel n("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
2020
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 I'm talking about, it is my first PHP script. Please advise what's wrong. The mail server, kind of unlikely, the first try it sent the mail (beginner's luck?), all of sudden, it went down? it's not on my box. Thanks.
16
2902
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 MySql folder on drive C. However, when I'm in Dreamweaver I click on Applications at the side, and the plus button to add a MySql database. It tells me to enter the
9
12405
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
1885
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 the use of eval() is required to execute it?" Given the following code, I'm able to evaluate/execute most expressions like: "a.b.c.d()"
0
1104
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 has ASCII diagrams. I built them using a fixed-width font, so looking at them in a proportional font may make my pretty drawings quite ugly.
1
2474
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 presses the submit button. - The submit button then calls a function that sets a asp:lable to that value selected. - PROBLEM: No matter what value the user selects, the asp:lable always
17
34724
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 fine. However the HTML have a SCRIPT tag that the browser should process, but
7
4774
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 mildly I've been thrown in at the deep end, in the past I've just done simple databases and that's been fine. Now, however I have to "roll out" various front ends to a single back end for initially 10 users (and the bosses have plans for this to go to...
12
1289
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 community's thoughts/comments on what I've done; improvements I can make, "don'ts" I should be avoiding, etc. I'm not so much bothered about the resulting data - for the moment it meets my needs. But any comment is welcome! #!/usr/bin/env python
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.