Welcome Guest, Not a member yet? Register   Sign In
How to check submit button
#1

[eluser]kurniawan joko purnomo[/eluser]
Hi My Name joko from indonesia.
I Have question about submit button.
Here the question.

I Have one form . Inside the form i have two submit button. First submit button name is "edit" and the second one is "delete".

How i can determine which people click ( edit or delete submit button ). Please help me.

Regards

Code:
<form method="post" name="article">
    <input type="hidden" name="id" value="2">
    <input type="submit" name="edit" value="edit">
    <input type="submit" name="delete" value="delete">
</form>
#2

[eluser]kurniawan joko purnomo[/eluser]
hi guys... help me
#3

[eluser]fesweb[/eluser]
I haven't tried this, but you can probably do something like this;
Code:
function process()
{
if($this->input->form('edit') !== FALSE)
{
}
if($this->input->form('delete') !== FALSE)
{
}
}
HOWEVER it will be easier to manage your controllers if you have those buttons call separate methods. You can either use links instead (add ID to url and you can dress them up to look like buttons with CSS), or create two separate forms for each record (one to delete and one to edit.

Then, your controller looks like this:
Code:
function edit()
{
}
function delete()
{
}
#4

[eluser]Wondering Coder[/eluser]
Since you only have two buttons to decide on. you can just do it like this:

Code:
$edit = $this->input->post('edit');
$delete = $this->input->post('delete');

if($edit)
{
.//edit something here
}
else
{
delete
}
#5

[eluser]kurniawan joko purnomo[/eluser]
[quote author="fesweb" date="1312103651"]I haven't tried this, but you can probably do something like this;
Code:
function process()
{
if($this->input->form('edit') !== FALSE)
{
}
if($this->input->form('delete') !== FALSE)
{
}
}
HOWEVER it will be easier to manage your controllers if you have those buttons call separate methods. You can either use links instead (add ID to url and you can dress them up to look like buttons with CSS), or create two separate forms for each record (one to delete and one to edit.

Then, your controller looks like this:
Code:
function edit()
{
}
function delete()
{
}
[/quote]
Thanks for reply with alternate one and work for me.
#6

[eluser]kurniawan joko purnomo[/eluser]
[quote author="Wondering Coder" date="1312242863"]Since you only have two buttons to decide on. you can just do it like this:

Code:
$edit = $this->input->post('edit');
$delete = $this->input->post('delete');

if($edit)
{
.//edit something here
}
else
{
delete
}
[/quote]
Thanks, and it works and helpful for me.... again ... thanks lot
#7

[eluser]InsiteFX[/eluser]
Why not just use CodeIgniter's url_helper anchor method?

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB