Expected identifier error on window.confirm, need help

P

Phil Powell

<script>
<!--

function willProceedToPay() {
var willPay = window.confirm('Vill du g' . String.fromCharCode(229) . '
till betaling?');
if (willPay) return true;
return false;
}

//-->
</script>


<form name=betalingForm method=post action=/membersites/betaling.php
onSubmit="return willProceedToPay()">

I can't figure out why I am getting this error. I have a form with a submit
that upon onSubmit will pop up a confirm window asking "Are you sure" (in
Norwegian I hope). Where did I go wrong?

Thanx
Phil
 
E

Erwin Moller

Phil said:
<script>
<!--

function willProceedToPay() {
var willPay = window.confirm('Vill du g' . String.fromCharCode(229) . '
till betaling?');
if (willPay) return true;
return false;
}

//-->
</script>


<form name=betalingForm method=post action=/membersites/betaling.php
onSubmit="return willProceedToPay()">

I can't figure out why I am getting this error. I have a form with a
submit that upon onSubmit will pop up a confirm window asking "Are you
sure" (in
Norwegian I hope). Where did I go wrong?

Hi Phil,

In Javascript use + for string concatination, no .

try this:
var willPay = window.confirm('Vill du g' + String.fromCharCode(229) + 'till
betaling?');
Thanx
Phil

Welcome. :)

Regards,
Erwin Moller
 
L

Lasse Reichstein Nielsen

Phil Powell said:

In HTML 4, the type attribute is required on script tags:

HTML comments are not necessary in script tags.
function willProceedToPay() {
var willPay = window.confirm('Vill du g' . String.fromCharCode(229) . '
till betaling?');

String concatenation in Javascript uses the "+" operator, not "." like
Perl. This is the error.
if (willPay) return true;
return false;

These two lines could just be written as
return willPay;
<form name=betalingForm method=post action=/membersites/betaling.php
onSubmit="return willProceedToPay()">

The action attribute value must be quoted, since it contains "/"
characters. I recommend quoting all attribute values.
I can't figure out why I am getting this error. I have a form with a submit
that upon onSubmit will pop up a confirm window asking "Are you sure" (in
Norwegian I hope). Where did I go wrong?

At the "." :)

/L
 
P

Phil Powell

I basically had a "blond moment" and forgot about the +. You see, the
script that contained the Javascript code is written in PHP and its
concatenation is "." and not "+". Basically, I got my syntax mixed up;
which I realized much later in the evening or earlier in the morning.

So thanx but I already got it. Finally. :(

Phil

PS: I have used <script> for years w/o fail, I use HTML 4.1
 
L

Lasse Reichstein Nielsen

Phil Powell said:
PS: I have used <script> for years w/o fail, I use HTML 4.1

No you don't. You *think* you use HTML 4.01, but a script tag
with no type attribute is not HTML 4.01, as any validator will
tell you.

Browsers are used to people writing incorrect HTML, so they happily
accept it anyway, but that doesn't make it correct.

/L 'Pedant? Me? Impossible!'
 
P

Phil Powell

Put it to you this way: if it ain't broke, don't fix it.

Not techie, but it's old practical sense from 'back in the day'

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top