|
Posted by bonehead on 09/26/87 11:29
Greetings,
I'm working on an e-mail form (btw many thanks to Philip Ronan for the
very cool email address format tester function, best I've seen so far).
I've been trying, with limited success, to produce a javascript alert
box which shows the user a validation error message. The error message
itself is dynamic, i.e., it's contained within a php variable.
I seem to be running into two issues:
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.
2. When the alert box does appear, the content of the web page behind
the alert box disappears, i.e., the page goes blank. When the user
clicks the OK button on the alert box, the blank web page remains, and
the user must click the Back button to return to the form.
The html that generates the form is wrapped inside a php function (the
file itself is php). The 'action' attribute of the form is "<?php echo
$PHP_SELF ?>". The form also contains a hidden field called 'action'
whose value is 'send_mail'.
When the user clicks the submit button, the script calls itself
recursively, and the $action variable's value, 'send_mail', is sent to a
switch. The switch calls a send_mail function, which performs all the
validation checks and generates an html error message if $myerrormessage
is not empty. This script was based on models provided in this book:
http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764557440.html
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.
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?
Navigation:
[Reply to this message]
|