Forum Moderators: coopster
My solution is to use another server side PHP script which will be the target of the Action attribute in your form. So, it can be done, but maybe not efficiently.
So, here is how I would do it in javascript. I am not sure how inaccurate I am since like, dsandall, you need to provide us with a scenario.
1) First of all, give your form a name <form name="form1">
2) Next, you have to decide WHEN to gather that form field value using the right event handler. If you will take the variable when the user types in a value, you can use an onChange event handler in the INPUT HTML tag.
Or when the visitor moves to the next variable, an onUnfocus event handler.
Or after the entire form is filled out, an onSubmit event handler or an onClick event handler in a button (non-submit type)
3) Then, create a Javascript function in you <HEAD> to submit to another PHP script on the server and grab that value with the server-side PHP file.
So, in your function, you can code it like this:
function ProcessPhpVariable() {
document.form1.submit();
}
Form1 will have the Action attribute directed to another PHP file on the server.
I can see this working, but it will take two PHPs to do the job. One on the client and one on the server.
When the server-side PHP script is executed, it will become your client-side PHP script and it will have the vale in a variable. Maybe not the most efficient way, but it will work.
Bruce
Like
<script language="Javascript">
var PhpVariable = document.form1.field1.value;
document.write ("<?php");
document.write ("$PhpVal=", PhpVariable);
document.write ("?>");
</script>
I can see this working...I have not tried it, but it sounds like an interesting idea. You may need an onChange event handler to kick off the Javascript.
If javascript has generated them, you can do pretty much any calculation javascript can do using php, and then php has the data before you even start.
If they are not on _your_ page... then you can use cURL to bring up the page, post values, and retrieve results, etc...