zeberrun Posted October 4, 2011 Posted October 4, 2011 in oscommerce 2.2 checkout_payment.php like below. after the customer checked the box, than the continue button was being active. the continue button was coming disabled. <?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td> <td class="main" align="right"><input type="Submit" value="<? echo IMAGE_BUTTON_CHECKOUT; ?>" disabled> in 2.3.1. button is assigned with function. how can i disable the continue button in first load of page?. <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e ', null, 'primary'); ?> (after the page loaded, java code works perfect. button is active when check the box, disable uncheck the box) // Output a jQuery UI Button function tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null) { static $button_counter = 1; $types = array('submit', 'button', 'reset'); if ( !isset($params['type']) ) { $params['type'] = 'submit'; } if ( !in_array($params['type'], $types) ) { $params['type'] = 'submit'; } if ( ($params['type'] == 'submit') && isset($link) ) { $params['type'] = 'button'; } if (!isset($priority)) { $priority = 'secondary'; } $button = tep_draw_button_top(); $button .= '<span class="tdbLink">'; thanks for your help
foxp2 Posted October 5, 2011 Posted October 5, 2011 <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e ', null, 'primary', array('disabled' => 'true')); ?> and add in catalog\includes\functions\html_output.php before : if (empty($title)) { $args[] = 'text:false'; } these lines : if ( isset($params['disabled']) && $params['disabled'] == 'true') { $args[] = 'disabled: true'; } and for a <a> link button : <script type="text/javascript"> $( "#element_id" ).button({ disabled : true }).click(function() {return false;}); </script>
zeberrun Posted October 6, 2011 Author Posted October 6, 2011 many thanks for reply, this modification works perfect but java script. <script type="text/javascript"> $( "#element_id" ).button({ disabled: true }).click(function() {return false;}); </script> when i added to html_output.php it turned to white page. can i use without java script is it correct?
foxp2 Posted October 6, 2011 Posted October 6, 2011 The "a" element does not have a "disabled" attribute (in Valid HTML). eg : catalog\includes\header.php for 'cart content' button in the header : this code is likely to work only in IE : echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart', tep_href_link(FILENAME_SHOPPING_CART), null, array('disabled' => 'true')) . the only way to disable this button : after these lines : <script type="text/javascript"> $("#headerShortcuts").buttonset(); add : $( "#tdb1" ).button({ disabled: true }).click(function() {return false;});
zeberrun Posted January 5, 2012 Author Posted January 5, 2012 i have searched the terms metioned above. i tried many choices but still button still does not work well. 1- i added to checkout_payment <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e ', null, 'primary', array('disabled' => 'true')); ? 2- i added to html_out.php if ( isset($params['disabled']) && $params['disabled'] == 'true') { $args[] = 'disabled: true'; } result button seems doubled. works but the content (written CONTINUE) is dim and double. choices in checkout_payment i gave and div id tag to button (it has class but has not div id) <div class="fl_right" align="right"><div id="test" class="bg_button2" onMouseOut="this.className='bg_button2';" onMouseOver="this.className='bg_button2-act';"><input type="Submit" value="<? echo IMAGE_BUTTON_CHECKOUT_PAYMENT; ?>" disabled> </div> i added javascript before and after div classes, nothing changed. the content is still dim and double. <script type="text/javascript"> $( "#test" ).button({ disabled: true }).click(function() {return false;}); </script> what is your opinion rgds
foxp2 Posted January 5, 2012 Posted January 5, 2012 @zeberrun change tep_draw_button in catalog\includes\functions\html_output.php with : function tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null) { static $button_counter = 1; $types = array('submit', 'button', 'reset'); if ( !isset($params['type']) ) { $params['type'] = 'submit'; } if ( !in_array($params['type'], $types) ) { $params['type'] = 'submit'; } if ( ($params['type'] == 'submit') && isset($link)) { $params['type'] = 'button'; } if (!isset($priority)) { $priority = 'secondary'; } // change : get id in $params array. if (!isset($params['id'])){ $idbutton = "tdb" . $button_counter . ""; }else{ $idbutton = $params['id']; $button_counter -= 1; } $button = '<span class="tdbLink">'; if ( ($params['type'] == 'button') && isset($link)) { $button .= '<a id="' . $idbutton . '" href="' . $link . '"'; if ( isset($params['newwindow']) ) { $button .= ' target="_blank"'; } } else { $button .= '<button id="' . $idbutton . '" type="' . tep_output_string($params['type']) . '"'; if ( isset($params['params']) ) { $button .= ' ' . $params['params']; } } $button .= '>' . $title; if ( ($params['type'] == 'button') && isset($link) ) { $button .= '</a>'; } else { $button .= '</button>'; } $button .= '</span><script type="text/javascript">$("#' . $idbutton . '").button('; $args = array(); if ( isset($icon) ) { if ( !isset($params['iconpos']) ) { $params['iconpos'] = 'left'; } if ( $params['iconpos'] == 'left' ) { $args[] = 'icons:{primary:"ui-icon-' . $icon . '"}'; } else { $args[] = 'icons:{secondary:"ui-icon-' . $icon . '"}'; } } if (empty($title)) { $args[] = 'text:false'; } // changes : disabled a button if ( isset($params['disabled']) ) { $args[] = 'disabled: true'; $activate = 'false'; } if (!empty($args)) { $button .= '{' . implode(',', $args) . '}'; } $button .= ').addClass("ui-priority-' . $priority . '").click(function() {return ' . $activate . ';}).parent().removeClass("tdbLink");</script>'; $button_counter++; return $button; } eg in catalog\checkout_payment.php : <div style="float: right;"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary', array('disabled' => 'true')); ?></div> eg in catalog\includes\header.php this code works : echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart', tep_href_link(FILENAME_SHOPPING_CART),null, array('disabled' => 'true')) . because i've added javascript click function in tep_draw_button (a simple variable $activate returns 'false' or nothing)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.