Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Simple function won't fire

Reply
Thread Tools

Simple function won't fire

 
 
Rod
Guest
Posts: n/a
 
      04-23-2006
I can't get this alert to show no matter what I do. Making me crazy.
One doesn't equal two...does it?

<html>
<head>
<title>Rider Survey</title>
<link rel="stylesheet" type="text/css" href="ez.css">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
<!-- Hide from odd browsers
function Checkcheck(){
If (1 != 2){
alert("This alert finally came up!");
return false;}
Else {return true;}
}
// stop hiding -->
</script>
</head>

The function is called from an "onsubmit" in the form tag, ie
<form name="survey" action="gdform.asp" method="POST" onsubmit="return
Checkcheck();">

Shouldn't the alert show every time the "Submit" button is clicked? I
haven't seen it so far. What up?

 
Reply With Quote
 
 
 
 
Quitchat
Guest
Posts: n/a
 
      04-23-2006
Hi Rod,
Are you sure it's " If " and " Else " rather than " if " and " else "?

Hope that helps.

Regards,
QC.

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      04-23-2006
Quitchat wrote on 23 apr 2006 in comp.lang.javascript:

> Hi Rod,
> Are you sure it's " If " and " Else " rather than " if " and " else "?
>


Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      04-23-2006
Rod said the following on 4/23/2006 1:17 AM:
> I can't get this alert to show no matter what I do. Making me crazy.
> One doesn't equal two...does it?
>
> <html>
> <head>
> <title>Rider Survey</title>
> <link rel="stylesheet" type="text/css" href="ez.css">
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <script type="text/javascript">
> <!-- Hide from odd browsers


I think that is the first time I have ever seen them called "odd browsers"

> function Checkcheck(){
> If (1 != 2){


If != if

> alert("This alert finally came up!");
> return false;}
> Else {return true;}


Else != else

Case matters.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      04-23-2006
Rod a écrit :
> I can't get this alert to show no matter what I do. Making me crazy.
> One doesn't equal two...does it?


<script type="text/javascript">
<!-- Hide from odd browsers
function Checkcheck(){
if (1 != 2){
alert("This alert finally came up!");
return false;
}
return true;
}
// stop hiding -->
</script>

it is 'if' and not 'If'



--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
TheBagbournes
Guest
Posts: n/a
 
      04-23-2006
ASM wrote:
> Rod a écrit :
>> I can't get this alert to show no matter what I do. Making me crazy.
>> One doesn't equal two...does it?

>
> <script type="text/javascript">
> <!-- Hide from odd browsers


What will the Javascript parser make of "<!--"?

Javascript one line comments are started with "//"

The script is not going to be parsed. Check Firefox's Javascript console.
 
Reply With Quote
 
Rod
Guest
Posts: n/a
 
      04-23-2006
Rod wrote:
> I can't get this alert to show no matter what I do. Making me crazy.
> One doesn't equal two...does it?
>
> <html>
> <head>
> <title>Rider Survey</title>
> <link rel="stylesheet" type="text/css" href="ez.css">
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <script type="text/javascript">
> <!-- Hide from odd browsers
> function Checkcheck(){
> If (1 != 2){
> alert("This alert finally came up!");
> return false;}
> Else {return true;}
> }
> // stop hiding -->
> </script>
> </head>
>
> The function is called from an "onsubmit" in the form tag, ie
> <form name="survey" action="gdform.asp" method="POST" onsubmit="return
> Checkcheck();">
>
> Shouldn't the alert show every time the "Submit" button is clicked? I
> haven't seen it so far. What up?


All who replied said the same thing and all were right. It's case
sensitive. Thanks to each of you for taking the time.
Rod

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      04-23-2006
TheBagbournes wrote:

> ASM wrote:
>> Rod a écrit :
>>> I can't get this alert to show no matter what I do. Making me crazy.
>>> One doesn't equal two...does it?

>>
>> <script type="text/javascript">
>> <!-- Hide from odd browsers

>
> What will the Javascript parser make of "<!--"?


Since there is no such thing as /the/ "Javascript parser", that is unknown.
At least current _JavaScript_ and JScript parsers will regard the following
text up to the newline as a comment. That is a known extension to
ECMAScript, but one that should not be relied upon (see below for details).

> Javascript one line comments are started with "//"


That is true for all ECMAScript implementations.

> The script is not going to be parsed.


That is only half the truth. Provided that

1. what was posted is HTML, or XHTML served as text/html (the latter is
recommended against), and

2. the SpiderMonkey JavaScript engine or Microsoft JScript is used,

the script /is/ going to be parsed. The `script' element is regarded as
CDATA there, and is therefore passed as-is to the respective script engine
up to the first ETAGO delimiter encountered ("</"; standards compliant) or
</script> end tag (some implementations). Due to the aforementioned
extension of ECMAScript, those script engines will ignore this line.

However, there are several reasons why it is strongly recommended against
using use "comment declaration" delimiters in that way:

- This extension of ECMAScript cannot be considered to be interoperable,
and there is no fallback.

- If the markup is XHTML, properly served as application/xhtml+xml or the
resource name includes a corresponding name suffix (.xhtm*), the `script'
element content is regarded PCDATA where all comments may be removed by
the (XML) parser before building the parse tree.

- It is completely unnecessary. HTML 2.0 is marked obsolete since 6 years
now, and pre-HTML-3.2 user agents went out of fashion long before; if
there is still one, or if it renders the content of a `script' element
within the `head' element, it is broken.

> Check Firefox's Javascript console.


The scripting language Firefox supports is called JavaScript for a reason.


PointedEars
--
Bill Gates isn't the devil -- Satan made sure hell
_worked_ before he opened it to the damned ...
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      04-23-2006
Rod wrote on 23 apr 2006 in comp.lang.javascript:

> All who replied said the same thing and all were right. It's case
> sensitive. Thanks to each of you for taking the time.


A simple case of JS case hypersensitivity?


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      04-24-2006
Thomas 'PointedEars' Lahn said the following on 4/23/2006 3:55 PM:
> TheBagbournes wrote:
>
>> ASM wrote:
>>> Rod a écrit :
>>>> I can't get this alert to show no matter what I do. Making me crazy.
>>>> One doesn't equal two...does it?
>>> <script type="text/javascript">
>>> <!-- Hide from odd browsers

>> What will the Javascript parser make of "<!--"?

>
> Since there is no such thing as /the/ "Javascript parser", that is unknown.


Yes it is. Your lack of understanding of the English language is evident
in your assumption about the statement.

> At least current _JavaScript_ and JScript parsers will regard the following
> text up to the newline as a comment. That is a known extension to
> ECMAScript, but one that should not be relied upon (see below for details).


Not a lot of what you write after your pedantics start is worth reading
sometimes.

>> Javascript one line comments are started with "//"

>
> That is true for all ECMAScript implementations.


Does that mean you have tested them ALL or are you assuming again?

>> The script is not going to be parsed.

>
> That is only half the truth. Provided that


It is not even half true.

> 1. what was posted is HTML, or XHTML served as text/html (the latter is
> recommended against), and


If it is HTML then it will get parsed by the Script Engine.

> 2. the SpiderMonkey JavaScript engine or Microsoft JScript is used,


Or any other script engine that honors the script tag.

> the script /is/ going to be parsed. The `script' element is regarded as
> CDATA there, and is therefore passed as-is to the respective script engine
> up to the first ETAGO delimiter encountered ("</"; standards compliant) or
> </script> end tag (some implementations).


Name one under 5 years old that stops at the first </ when being served
HTML.

> Due to the aforementioned extension of ECMAScript, those script engines
> will ignore this line.


ECMAScript is irrelevant. It is not an "extension of ECMAScript", it is
an extension of Javascript and JScript. There is a reason why the script
tag doesn't say:

<script type="text/ecmascript">

> However, there are several reasons why it is strongly recommended against
> using use "comment declaration" delimiters in that way:
>
> - This extension of ECMAScript cannot be considered to be interoperable,
> and there is no fallback.


Sure there is. Name a browser that balks on it with HTML.

> - If the markup is XHTML, properly served as application/xhtml+xml or the
> resource name includes a corresponding name suffix (.xhtm*), the `script'
> element content is regarded PCDATA where all comments may be removed by
> the (XML) parser before building the parse tree.


There are no suffixes/extensions on the Web. But, you should feed a
"resource" (as you refer to it) with a "suffix" of .xhtml to IE sometime.

> - It is completely unnecessary. HTML 2.0 is marked obsolete since 6 years
> now, and pre-HTML-3.2 user agents went out of fashion long before; if
> there is still one, or if it renders the content of a `script' element
> within the `head' element, it is broken.


It wasn't "broken", it was doing what it was designed to do.

>> Check Firefox's Javascript console.

>
> The scripting language Firefox supports is called JavaScript for a reason.


You should learn how to read plain English, and apply common sense to
it, before babbling your BS. Especially in an English group. Your BS
behavior may work for you in de.* but I don't post there.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fire with fire Little Green Eyed Dragon Digital Photography 0 08-16-2006 12:15 AM
On fighting fire with fire... skip@pobox.com Python 16 08-01-2005 07:09 PM



Advertisments