I am working on php phalcon with XAMPP server.
I have a controller called PrescriptionsController. It has several action methods. In the index view, I fill a <form> to make the prescription then when I hit a save button, a javascript function is called which calls another action method in the controller.
The thing is that the I can dynamically increase the number of textboxes depending upon the number of medicines I want to prescribe to the patient. This is why it is necessary that when I hit save, the javascript function is called in order to check the number of textboxes and the values that they contain.
Now, I wish to know that how can I achieve this? Okay I can read the values from the textboxes and insert them into an array, but I actually have two arrays and I want to know how to pass them as parameters to the action method which I am calling in the javascript function? One more thing, if I do something like this:
<script>
function generate()
{
//necessary code
open("actionmethod");
}
</script>
Along with this:
<form method="post">
<-- form body -->
<input type="submit" onclick="generate()">
</form>
My $_POST returns empty. How can I solve this too?
So my two questions are: How to pass parameters to action methods called in javascript? How to get $_POST values?
NOTE: I need two submit buttons and I am using two as well. One to preview and the other to save.
Aucun commentaire:
Enregistrer un commentaire