CodeIgniter Forums
How to Apply style and JS to form_submit ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to Apply style and JS to form_submit ? (/showthread.php?tid=18542)



How to Apply style and JS to form_submit ? - El Forum - 05-10-2009

[eluser]minoh[/eluser]
hi guys,

someone know how to apply style and JS to a form_submit, in my former html i have got this submit button :
Code:
&lt;input id="button"&gt;&lt;br/><br/>

but now i want to apply it to my form_submit, and i dont know howto !!


How to Apply style and JS to form_submit ? - El Forum - 05-10-2009

[eluser]davidbehler[/eluser]
More or less taken from the User Guide:
Code:
$data = array(
    'name' => 'button',
    'id' => 'button',
    'value' => 'Submit',
    'class' => 'myclass'
);
$js = 'onClick="some_function()"';
echo form_submit($data, '', $js);



How to Apply style and JS to form_submit ? - El Forum - 05-10-2009

[eluser]minoh[/eluser]
this is what i put in my login body view :
Code:
$bdata = array(
    'name' => 'button',
    'id' => 'button',
    'value' => 'Submit',
    'type' => 'image',
    'src' => 'pathToSrc'

);
$js = array(
    'onmouseover'=>'over_login()',
    'onmouseout'=>'out_login()'
);
echo form_submit($data, '', $js);
but i just get a trasparent button out of my login box with juste the submit value.


How to Apply style and JS to form_submit ? - El Forum - 05-10-2009

[eluser]davidbehler[/eluser]
Try removing the 'type' => 'image' party rfom the $data array. I'm guessing that overrides the type="submit" that's set by the form_submit() function.