Welcome Guest, Not a member yet? Register   Sign In
form image as button type
#1

[eluser]pallavi312[/eluser]
hello,

i have button image. i want to able able to put that image as button in form. i have used form_image like this in helpr.

function form_image($data = '', $src = '', $alt='', $extra = '', $val='', $id='')
{
$defaults = array('type' => 'image', 'name' => (( ! is_array($data)) ? $data : ''), 'src' => $src, 'alt' => $alt, 'value' => $val, 'id' => $id);
return "<input "._parse_form_attributes($data, $defaults).$extra." />";

in controller
$manage_data['form_elem'] = array("submit"=>array("name"=>"submit","id"=>"submit","src" => base_url()."images/action_page_update.jpg","value"=>"Submit", "onclick"=>"return confirmupdate(this)")


in view
<?=form_image($form_elem['submit'])?>

when i click on that image button my form get submitted . i want this image only as button type not submit type.

how to do this?
#2

[eluser]imn.codeartist[/eluser]
[quote author="pallavi312" date="1263381965"]hello,

i have button image. i want to able able to put that image as button in form. i have used form_image like this in helpr.

function form_image($data = '', $src = '', $alt='', $extra = '', $val='', $id='')
{
$defaults = array('type' => 'image', 'name' => (( ! is_array($data)) ? $data : ''), 'src' => $src, 'alt' => $alt, 'value' => $val, 'id' => $id);
return "<input "._parse_form_attributes($data, $defaults).$extra." />";

in controller
$manage_data['form_elem'] = array("submit"=>array("name"=>"submit","id"=>"submit","src" => base_url()."images/action_page_update.jpg","value"=>"Submit", "onclick"=>"return confirmupdate(this)")


in view
<?=form_image($form_elem['submit'])?>

when i click on that image button my form get submitted . i want this image only as button type not submit type.

how to do this?[/quote]

Create your own helper ... simple
#3

[eluser]flaky[/eluser]
no need to write a helper, do this
example
Code:
echo form_input(array('type' => 'image', 'src' => 'img.gif', 'name' => 'submit'));
#4

[eluser]imn.codeartist[/eluser]
[quote author="flaky" date="1263389972"]no need to write a helper, do this
example
Code:
echo form_input(array('type' => 'image', 'src' => 'img.gif', 'name' => 'submit'));
[/quote]

@flakyTonguelease Read this line of pallavi312

"when i click on that image button my form get submitted . i want this image only as button type not submit type.

how to do this?"
#5

[eluser]flaky[/eluser]
Code:
echo form_input(array('type' => 'image', 'src' => 'img.gif', 'name' => 'submit', 'onclick' => 'return false'));




Theme © iAndrew 2016 - Forum software by © MyBB