Christian Pflugradt wrote:I'm pretty sure you cannot do this with a html form post. What you are looking for is called a partial submit. It will only update part of your content but not the whole window. You can use Ajax to achieve this. Other backends like Java EE / Java Server Faces also offer this functionality by default.
If I were you I would probably start with the w3schools Ajax tutorial.
Good luck!
Christian Pflugradt wrote:you will have to call a javascript function when clicking your button which will post the code to your backend, for example a second php script.
Christian Pflugradt wrote:
To my knowledge with HTML and PHP alone it's simply not possible. I'd advice you take a bit of time to make yourself familiar with how HTML, Javascript, Ajax and web servers are related to each other.
Christian Pflugradt wrote:one way to achieve your desired result would be to call a Javascript function from your button which will send an Ajax request to a web server (for example PHP based) to evaluate some parameters and send a reply which Javascript can again evaluate and write into your target DOM elements to populate your second tab without refreshing the whole page.
Reem arfaj wrote:
Christian Pflugradt wrote:one way to achieve your desired result would be to call a Javascript function from your button which will send an Ajax request to a web server (for example PHP based) to evaluate some parameters and send a reply which Javascript can again evaluate and write into your target DOM elements to populate your second tab without refreshing the whole page.
I am implementing what you explain in above. As a conclusion:
1- I should create javascript function that will be called when I press some button in the form.
2- javascript will send Ajax request to php file.
3- php file will send replay to the javascript.
4- javascript will change the content of the second tab with the result got from the php.
Now, my question is: what about the form in html that collect user input? How can I determine the "action" parameter?
<form id='myform' enctype='multipart/form-data' name='myForm' method='post' action="calculateResults.php">
SOME INPUTS HERE
<p><input type='button' name="mybut" value='Run' onclick="[color=red]jsFunction()"></p>
</form>
[/color]
Do you mean that I should remove the form tag and pass all inputs as parameters of jsFunction?
Hope you getting my point.
Thanks a lot
Reem arfaj wrote:
Reem arfaj wrote:
Christian Pflugradt wrote:one way to achieve your desired result would be to call a Javascript function from your button which will send an Ajax request to a web server (for example PHP based) to evaluate some parameters and send a reply which Javascript can again evaluate and write into your target DOM elements to populate your second tab without refreshing the whole page.
I am implementing what you explain in above. As a conclusion:
1- I should create javascript function that will be called when I press some button in the form.
2- javascript will send Ajax request to php file.
3- php file will send replay to the javascript.
4- javascript will change the content of the second tab with the result got from the php.
Now, my question is: what about the form in html that collect user input? How can I determine the "action" parameter?
<form id='myform' enctype='multipart/form-data' name='myForm' method='post' action="calculateResults.php">
SOME INPUTS HERE
<p><input type='button' name="mybut" value='Run' onclick="jsFunction()"></p>
</form>
Do you mean that I should remove the form tag and pass all inputs as parameters of jsFunction?
Hope you getting my point.
Thanks a lot
Christian Pflugradt wrote:one way to achieve your desired result would be to call a Javascript function from your button which will send an Ajax request to a web server (for example PHP based) to evaluate some parameters and send a reply which Javascript can again evaluate and write into your target DOM elements to populate your second tab without refreshing the whole page.
Bear Bibeault wrote:1) POST expects parameter encoded in the body, not on the URL.
2) Use jQuery to make all this much much easier.
Christian Pflugradt wrote:one way to achieve your desired result would be to call a Javascript function from your button which will send an Ajax request to a web server (for example PHP based) to evaluate some parameters and send a reply which Javascript can again evaluate and write into your target DOM elements to populate your second tab without refreshing the whole page.
Don't get me started about those stupid light bulbs. |