Buttons for sending images to Codeigniter - what am I missing?

I have the following Codeigniter code to display a form with two buttons for submitting an image. I need to know which button was pressed by the user. Usually I just refer to the name or value that is passed, but nothing is transmitted from these buttons. All other fields / text fields, etc. On the form go through ok, but none of these buttons ....

.... what am I missing? I pondered this for several hours and did not help on the net!

That

<? 
            $attributes = array('id' => 'formname','name' => 'formname');
            echo form_open('processform',$attributes); 
            $btn_input = array(
                'subtype'   => ''
            );
            echo form_hidden($btn_input);

            $btn_search = array(
                'type'  => 'image',
                'src'       => '/graphics/button1.gif',
                'id'        => 'button1',
                'name'  => 'button1',
                'value' => 'button1'
            );
            ?>
            <div id='1stbutton' style='text-align: center'>
                <? echo form_input($btn_search);?>
            </div> 

            <?
            $btn_search = array(
                'type'  => 'image',
                'src'       => '/graphics/button2.gif',
                'id'        => 'button2',
                'name'  => 'button2',
                'value' => 'button2'
            );
            ?>
            <div id='2ndbutton' style='text-align: center'>
                <? echo form_input($btn_search);?>
            </div>

            <? echo form_close(); ?>
+3
source share
2 answers

( Zend )! , "" = . , , , "_x" "_y" (Ex 'Button2_x') $_Post .

if(isset($_POST['button2_x']))
{
  //button2 was clicked! 
}
else if(isset($_POST['button1_x']))
{
  //button1 was clicked go on!
}

. , Codeigniter

+2

Codeigniter, HTML. "" x y, , "0" , . value .

http://www.w3.org/TR/html401/interact/forms.html

, . x , y - . name.x = x-value name.y = y-value, "name" - name, x y - x y .

, $_POST. var_dump() , , 1 ( ):

array(3) {
  ["subtype"]=>
  string(0) ""
  ["button1_x"]=>
  string(1) "0"
  ["button1_y"]=>
  string(1) "0"
}

, , , , :

if (isset($_POST['button1_x'])) // Button 1 clicked

, , , image. submit <button type="submit">. HTML , IE6...

<button> IE6 HTML- post value! , . , isset(), value, . , .

+2

All Articles