Hi,
I’ve read up a little bit on the ONBLUR (Javascript) event, and I would like to include it in a PHP file, and keep as much code invisible to the user, by using PHP. Is this possible ?
The objective is, when the user leaves the email field on a form, to insert one row into the MySQL db. I would like the insert code not to be visible to the user. At present, the PHP file does the MySQL connect, etc, at the start, displays some html, and the field in question is coded as:
<tr><td width="130"><FONT SIZE="2" COLOR="#66CCFF" FACE="Verdana, Arial">
Email</td>
<td>
<input type="text" size="25" name="email"></td></tr>
I would like to modify the above code, to include the ONBLUR event, so that when the user leaves the field ‘email’, one row is inserted into the MySQL db. Can the ONBLUR event simply call a PHP function ? I realise it can call a Javascript function, as per the example below:
Enter email address <INPUT TYPE="text" VALUE="" NAME="userEmail" onBlur=addCheck()>
<script type="text/javascript" language="JavaScript">
function addCheck() {
alert("Please check your email details are correct before submitting")
}
</script>
I would like the function that is called to be defined in the PHP code. I have noticed code like:
$this->tb->add("disk.gif", "javascript:window.parent.view.save()", "Save", "Save Changes");
in PHP code, so I assume you can even call Javascript from PHP ??
All I want to do is define a function in the (same) PHP file, that inserts the row into the MySQL db, and the ONBLUR event to call that function.
Thanks,
Peter