0

I know this is a somewhat strange request and is probably not feasable, but I thought I would ask anyway :)

I have a form, and on the final page of the form it displays all of the results of the user's entries. The problem is some of these results are calculated by a complicated javascript function that then displays the proper result. For example, the javascript takes a number for the arrival location specified on the form and then finds that number to mean "Atlanta". Javascript then places the right value in a table via the "innerhtml" dom property.

When the user clicks "Submit" on the final page an e-mail is sent to the user via php script. Is there anyway to capture the javascript output for use in a php variable.

Basically I want to capture the innerhtml value javascript places and use this value in my PHP script. I am trying to avoid re-writing the javascript calculations in PHP and was looking for a way to pass this information from the javascript function to the php script. Any ideas?

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by cwarn23
0

While I myself don't know how to do this, I can say this, with enough time and resources anything can be done with php.

0

Add hidden fields to the form with the Submit button, the values can then be retreived using $_POST or $_GET in PHP.

0

xan is right and the code for it is something like the below. First in your form add the following code:

<input type="hidden" value="" name="js" id="js">

Then to update its value in the javascript function use the following javascript:

<script>
document.getElementById("js").innerHTML="new value";
//or
document.getElementById("js").value="new value";
</script>

Edited by cwarn23: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.