views:

554

answers:

1

I have a page with three forms.

I'd like to run different db calls corresponding to the button clicked.

I have a 2 lib functions. One validates, and the passes it to the _submit function...

How can I separate the _submit function based on which submit button is clicked? alt text

+1  A: 

You can either set up 3 different forms, each with its own action, or you can set different values for each submit button and take action based on the value of the submit variable.

<form name="my_form" action="some/action/validate/">
    <input type="submit" value="paypal" name="submit" />
    <input type="submit" value="promo" name="submit" />
    <input type="submit" value="employee" name="submit" />
</form>

function validate() {
    my_action = $this->input->post("submit");
    if (my_action = "paypal") {
        // Your logic
    } ... etc
}
Sean Vieira
I'm a super-beginner. Could you give an example of the action?
Kevin Brown
@Kevin -- glad to do so!
Sean Vieira
def validate()? Not a Pythonista by any chance are you? ;)
John McCollum
@John *Laughs* I am, and proud of it! I doubt the browsers care though ;-) Fixed!
Sean Vieira