mpps Posted November 2, 2012 Posted November 2, 2012 Hi, Is there a possibility to add onclick behavior to tep_draw_button function? I've done this by: <a onclick="this.form.action.value='list';this.form.submit();"><?php echo tep_draw_button(IMAGE_UPDATE, 'refresh'); ?></a> But I want also know, there is a possibility to add onclick behavior to tep_draw_button function... Regards
g2777 Posted November 2, 2012 Posted November 2, 2012 Yes, there is. The function that draws the buttons looks like this: tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null) So, for yours, you would put the onclick in the params. It might look something like this: tep_draw_button(IMAGE_UPDATE, 'refresh', null, null, 'onclick="this.form.action.value='list';this.form.submit();"') Note that I said something like this. I don't think that this would work because of the single quotes in value='list'. They may need to be escaped first with \. So it might end up looking like: tep_draw_button(IMAGE_UPDATE, 'refresh', null, null, 'onclick="this.form.action.value=\'list\';this.form.submit();"') Not sure. Javascript isn't my forte so I don't tend to use it very often. The two nulls in the middle are for a html hyperlink and to set the priority of the button, respectively. The priority can be primary or secondary and denotes whether or not the button is made more prominent in colour (secondary is faded slightly.) Hope that helps. If not, maybe someone can correct me and I can learn something. :D Not enough time in the day. Need a time machine... Would build one, but not enough time. Ironically.
mpps Posted November 2, 2012 Author Posted November 2, 2012 @@g2777 Thanks for Your reply! But Your code is not working... But I have done this!! B) The correct solution is: tep_draw_button(IMAGE_UPDATE, 'refresh', null, null, array('params' => 'onclick=\'this.form.action.value="list";this.form.submit();\'')) And YES, You must be carefull which quotes You use!!! It may also look like this: tep_draw_button(IMAGE_UPDATE, 'refresh', null, null, array('params' => 'onclick="this.form.action.value=\'list\';this.form.submit();"')) Regards!
g2777 Posted November 2, 2012 Posted November 2, 2012 Good job. See, I did learn something... B) Glad you got it. Not enough time in the day. Need a time machine... Would build one, but not enough time. Ironically.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.