You are here: Re: Javascript alert question « PHP Programming Language « IT news, forums, messages
Re: Javascript alert question

Posted by Wayne on 10/18/05 08:35

On Mon, 17 Oct 2005 10:21:27 -0700, bonehead <sendmenospam@here.net>
wrote:

>1. I can raise the alert box, but I can't pass the string contained in
>the $myerrormessage variable. Clearly I don't quite have the syntax just
>right.

You have to output your error messages as proper Javascript code; this
might involve escaping various characters that have meaning in
Javascript or HTML.

>2. When the alert box does appear, the content of the web page behind
>the alert box disappears, i.e., the page goes blank.

This can happen depending on how your javascript is being called. If
you have something like this:

<a href="javascrpt:callSomeFunction();">Click Me</a>

Then this will cause the browser to redirect to a blank page.

>Currently I'm rendering the error message via another php function which
>produces the html containing $myerrormessage. This works just fine, of
>course, but I'm afraid some wiseguy web developer out there will look at
>it and proceed to tell me all about how lame it is.

It doesn't sound too bad.

>Can I add an onclick attribute to the form, to call a javascript
>function inside the <body> tag of the html which renders the form? Does
>anyone have an example of what I'm looking for?

Try hooking into the onsubmit event of the form. You can return false
to cancel the submit or return true to allow it. In that function,
you can you validation and show any alert boxes.

Later,

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация