|
 |
beginning_javascript thread: Why doesn't this work?
Message #1 by "Michael Giuffrida" <mpg1106@c...> on Thu, 28 Mar 2002 21:58:55
|
|
Why doesn't this code work?
<HTML>
<HEAD>
<TITLE>All American Idiots</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function butPress(time)
{
if (time == 1)
{
alert("Ow!! That hurt! Why on Earth did you do that???\n\nYou're a
BIG FAT MEANY!!");
document.form1.butPressMe.value="Well, I guess you can press me...";
document.form1.butPressMe.onclick="butPress(2)";
}
else
{
alert("end");
}
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#000000" TEXT="#FFFFFF">
<DIV ALIGN="CENTER">
<FORM NAME="form1">
<INPUT TYPE="button" NAME="butPressMe" VALUE="Please Press Me--I'm Begging
You!!" onclick="butPress(1)">
</FORM>
</BODY>
</HTML>
Message #2 by "Kirk Sculland" <ksculland@h...> on Fri, 29 Mar 2002 00:37:18
|
|
In the form you have called a function butPressMe
and the function you made is call butPress
also after you fix that you my need to give the for
an ID as well... ie ID = "ButPressMe"
Hope this helps...
Kirk Sculland
********************************************************
> Why doesn't this code work?
> <HTML>
<> HEAD>
<> TITLE>All American Idiots</TITLE>
> <SCRIPT LANGUAGE="JavaScript">
f> unction butPress(time)
{>
> if (time == 1)
> {
> alert("Ow!! That hurt! Why on Earth did you do that???\n\nYou're
a
B> IG FAT MEANY!!");
> document.form1.butPressMe.value="Well, I guess you can press
me...";
> document.form1.butPressMe.onclick="butPress(2)";
> }
> else
> {
> alert("end");
> }
>
}>
<> /SCRIPT>
> </HEAD>
>
> <BODY BGCOLOR="#000000" TEXT="#FFFFFF">
<> DIV ALIGN="CENTER">
<> FORM NAME="form1">
<> INPUT TYPE="button" NAME="butPressMe" VALUE="Please Press Me--I'm
Begging
Y> ou!!" onclick="butPress(1)">
<> /FORM>
<> /BODY>
<> /HTML>
Message #3 by "Kirk Sculland" <ksculland@h...> on Fri, 29 Mar 2002 00:41:58
|
|
Oops i noticed that the function that you called was called
butPress
Anyways. Try the ID = "butPressMe"
Kirk Sculland
> Why doesn't this code work?
> <HTML>
<> HEAD>
<> TITLE>All American Idiots</TITLE>
> <SCRIPT LANGUAGE="JavaScript">
f> unction butPress(time)
{>
> if (time == 1)
> {
> alert("Ow!! That hurt! Why on Earth did you do that???\n\nYou're
a
B> IG FAT MEANY!!");
> document.form1.butPressMe.value="Well, I guess you can press
me...";
> document.form1.butPressMe.onclick="butPress(2)";
> }
> else
> {
> alert("end");
> }
>
}>
<> /SCRIPT>
> </HEAD>
>
> <BODY BGCOLOR="#000000" TEXT="#FFFFFF">
<> DIV ALIGN="CENTER">
<> FORM NAME="form1">
<> INPUT TYPE="button" NAME="butPressMe" VALUE="Please Press Me--I'm
Begging
Y> ou!!" onclick="butPress(1)">
<> /FORM>
<> /BODY>
<> /HTML>
Message #4 by "Michael Giuffrida" <mpg1106@c...> on Fri, 29 Mar 2002 22:40:45
|
|
> Oops i noticed that the function that you called was called
b> utPress
>
A> nyways. Try the ID = "butPressMe"
>
K> irk Sculland
>> Why doesn't this code work?
> > <HTML>
<> > HEAD>
<> > TITLE>All American Idiots</TITLE>
> > <SCRIPT LANGUAGE="JavaScript">
f> > unction butPress(time)
{> >
> > if (time == 1)
> > {
> > alert("Ow!! That hurt! Why on Earth did you do that???\n\nYou're
a>
B> > IG FAT MEANY!!");
> > document.form1.butPressMe.value="Well, I guess you can press
m> e...";
> > document.form1.butPressMe.onclick="butPress(2)";
> > }
> > else
> > {
> > alert("end");
> > }
> >
}> >
<> > /SCRIPT>
> > </HEAD>
> >
> > <BODY BGCOLOR="#000000" TEXT="#FFFFFF">
<> > DIV ALIGN="CENTER">
<> > FORM NAME="form1">
<> > INPUT TYPE="button" NAME="butPressMe" VALUE="Please Press Me--I'm
B> egging
Y> > ou!!" onclick="butPress(1)">
<> > /FORM>
<> > /BODY>
<> > /HTML>
Message #5 by "TurnenT" <turnent@c...> on Fri, 29 Mar 2002 22:08:11 -0800
|
|
Hmmmm... I have no clue why this doesn't work...but the problem would be
with the highlighted line below...
document.form1.butPressMe.onclick="butPress(2)"; // <---- This line
didn't work
I'm guessing that function or something isn't allowed...
I tryed changing your last 'else' into an 'else if'...but no luck...
<HTML>
<HEAD>
<TITLE>All American Idiots</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function butPress(time)
{
if (time == 1)
{
alert("Ow!! That hurt! Why on Earth did you do that??? \n \n You're a
BIG FAT MEANY!!");
document.form1.butPressMe.value="Well, I guess you can press me...";
document.form1.butPressMe.onclick="butPress(2)"; // <---- This line
didn't work
}
else if (time != 1)
{
alert("end");
}
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#000000" TEXT="#FFFFFF">
<DIV ALIGN="CENTER">
<FORM NAME="form1">
<INPUT TYPE="button" NAME="butPressMe" VALUE="Please Press Me--I'm Begging
You!!" onclick="butPress(1)">
</FORM>
</DIV>
</BODY>
</HTML>
----- Original Message -----
From: "Michael Giuffrida" <mpg1106@c...>
To: "Beginning JavaScript" <beginning_javascript@p...>
Sent: Friday, March 29, 2002 10:40 PM
Subject: [beginning_javascript] Re: Why doesn't this work?
> > Oops i noticed that the function that you called was called
> butPress
>
> >
> A> nyways. Try the ID = "butPressMe"
>
> >
> K> irk Sculland
> >> Why doesn't this code work?
>
> > > <HTML>
> <> > HEAD>
> <> > TITLE>All American Idiots</TITLE>
>
> > > <SCRIPT LANGUAGE="JavaScript">
> f> > unction butPress(time)
> {> >
> > > if (time == 1)
> > > {
> > > alert("Ow!! That hurt! Why on Earth did you do that???\n\nYou're
> a>
> B> > IG FAT MEANY!!");
> > > document.form1.butPressMe.value="Well, I guess you can press
> m> e...";
> > > document.form1.butPressMe.onclick="butPress(2)";
> > > }
> > > else
> > > {
> > > alert("end");
> > > }
> > >
> }> >
> <> > /SCRIPT>
>
> > > </HEAD>
>
> > >
>
> > > <BODY BGCOLOR="#000000" TEXT="#FFFFFF">
> <> > DIV ALIGN="CENTER">
> <> > FORM NAME="form1">
> <> > INPUT TYPE="button" NAME="butPressMe" VALUE="Please Press Me--I'm
> B> egging
> Y> > ou!!" onclick="butPress(1)">
> <> > /FORM>
> <> > /BODY>
> <> > /HTML>
>
> ---
>
> Improve your web design skills with these new books from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
>
|
|
 |