Hi everyone
I need a bit of help with a problem involving HTML, JavaScript and PHP which I'm hoping someone here can help me with.
I have a working PHP script which uses a FORM section to get data input, which actions itself to do some PHP and JavaScript calculations etc, and it then opens a second PHP script to display the results. Now, all of this works perfectly, or at least how it was originally designed.
What I am trying to do is to do away with the second PHP script, and display the results (of the calculations) within the same page.
I have found a bit of code which will probably do what I want, but I just need a bit of help. This is part of the code...
<FORM method="POST">
<div id="example">
<P>This text is already in the DIV</P>
</div>
<input type="button" name="name" value="Hello" onclick="document.getElementById('example').innerHTML='<p>Hello</p>'">
</FORM>
When this is run, it's obviouse that the text "This text is already in the DIV" will be magically replaced with "Hello".
What I would really like to know how I can get a 2 or 3 hundred line PHP/JavaScript section of code, mostly complex calculations with an output basically consisting of 6 times (05:35 08:49 and so on) into the onclick above where the Hello is?
For example, could I put all the calculations into a function or something similar, and put just the function call where the Hello is?
Or maybe there is a better or more efficient way of doing it?
Thanks
Terry