"Invalid return" error

X

Xerxes

Hi,
I get the "Invalid return" error (in Javascript console) when I run
this piece of code:

<a href="javascript:if (document.dc_form.tn.value == ''' &&
document.dc_form.cid.value == '') { alert('You have not made a
selection. Please select one of the fields first.');return false; }
document.dc_form.submit();">Go!</a>

If I remove the "return false;", it displayes the alert and continues
to what it is NOT supposed to do.

TIA.
 
L

Lee

Xerxes said:
Hi,
I get the "Invalid return" error (in Javascript console) when I run
this piece of code:

<a href="javascript:if (document.dc_form.tn.value == ''' &&
document.dc_form.cid.value == '') { alert('You have not made a
selection. Please select one of the fields first.');return false; }
document.dc_form.submit();">Go!</a>

If I remove the "return false;", it displayes the alert and continues
to what it is NOT supposed to do.

That's a really bad idea.
The javascript: pseudo-protocol was designed to load the value of the Javascript
expression as the new contents of the page. Returning false doesn't make any
sense. Neither does submitting the form from within the expression. If you
don't want a link, don't use a link. Use a button.

http://www.jibbering.com/faq/#FAQ4_24


--
 

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

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top