Reputation: 23
I have a form with 2 submit buttons , I need to give 2 actions for the form based on the submit button I click,How can this be achieved in codeigniter,Thanks Friends. Here is the sample code.
<?php
$attributes = array('name' => 'frmdisplay');
echo form_open('display/goto1', $attributes);
?>
<input type="submit" class="button" value="Showone" name="goto1btn" />
<input type="submit" class="button" value="Showtwo" name="goto2btn" />
Here how can i provide action to both the pages display/goto1 and display/goto2 based on submit btn pressed. THat means if first submit button is pressed thwn action should be display/goto1 and for second submit button action should be display/goto2.
Upvotes: 0
Views: 2431
Reputation: 13630
If I'm not mistaken, isn't the name
of the submit button passed as a key in the post
data? If so, you can just check that:
if (!empty($this->input->post("goto1btn")))
{
// goto1btn pressed
}
else if (!empty($this->input->post("goto2btn")))
{
// goto2btn pressed
}
else
{
// no button pressed
}
Upvotes: 2