|
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]
|