Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Radio button to be automatic select


Guest

Recommended Posts

Posted

hi, i am trying to get the radio button for my only payment option be selected automaic , i have been looking for the answer all over the forum but i am still unsure how to achieve this....

i have attached an image so you can see what i am on trying to say

 

paymentoption.jpg

Posted

A snippet I found a couple of years ago,

 

Default payment method

 

in catalog/checkout_payment.php replace

 

<td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
} else {
echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
}
?>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
<td class="main" align="right">
<?php


 

with

 

<td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
// Start Setting a default payment
} else {

if ( (!$payment) && ($i==0) ) {

echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
// End Setting a default payment
} else {
echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
} // Setting a default payment
}
?>

 

It doesn't look quite right and I think it should have this on the end but I have not tested it

 

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
<td class="main" align="right">
<?php

 

HTH

 

G

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Posted

A snippet I found a couple of years ago,

 

Default payment method

 

in catalog/checkout_payment.php replace

 

<td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
} else {
echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
}
?>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
<td class="main" align="right">
<?php


 

with

 

<td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
// Start Setting a default payment
} else {

if ( (!$payment) && ($i==0) ) {

echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
// End Setting a default payment
} else {
echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
} // Setting a default payment
}
?>

 

It doesn't look quite right and I think it should have this on the end but I have not tested it

 

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
<td class="main" align="right">
<?php

 

HTH

 

G

 

hi , thanks for the info, my code is different to your code, can you take a look at my file please

 

<?php
/*
 $Id: checkout_payment.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// BOF: Store Mode
// if we do not want to allow checkout, send them back to cart page
 if (STORE_MODE == 'Closed') {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }
// EOF: Store Mode

// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

// if there is nothing in the customers cart, redirect them to the shopping cart page
 if ($cart->count_contents() < 1) {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
 if (!tep_session_is_registered('shipping')) {
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 }

// avoid hack attempts during the checkout procedure by checking the internal cartID
 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
   if ($cart->cartID != $cartID) {
     tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
   }
 }

// if we have been here before and are coming back get rid of the credit covers variable
if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');  //CCGV

// Stock Check
 if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
       tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
       break;
     }
   }
 }

// if no billing destination address was selected, use the customers own address as default
 if (!tep_session_is_registered('billto')) {
   tep_session_register('billto');
   $billto = $customer_default_address_id;
 } else {
// verify the selected billing address
   if ( (is_array($billto) && empty($billto)) || is_numeric($billto) ) {
   $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
   $check_address = tep_db_fetch_array($check_address_query);

   if ($check_address['total'] != '1') {
     $billto = $customer_default_address_id;
     if (tep_session_is_registered('payment')) tep_session_unregister('payment');
   }
 }
 }

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;
 require(DIR_WS_CLASSES . 'order_total.php');// CCGV
 $order_total_modules = new order_total;// CCGV
 if (!tep_session_is_registered('comments')) tep_session_register('comments');
 if (isset($HTTP_POST_VARS['comments']) && tep_not_null($HTTP_POST_VARS['comments'])) {
   $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
 }

 $total_weight = $cart->show_weight();
 $total_count = $cart->count_contents();
 $total_count = $cart->count_contents_virtual(); // CCGV

// load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT);

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<?php
// BOF: WebMakers.com Changed: Header Tag Controller v1.0
// Replaced by header_tags.php
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
 require(DIR_WS_INCLUDES . 'header_tags.php');
} else {
?> 
 <title><?php echo TITLE; ?></title>
<?php
}
// EOF: WebMakers.com Changed: Header Tag Controller v1.0
?>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
var selected;
<?php /* following jscript function ADDED FOR CCGV */ ?>
var submitter = null;
function submitFunction() {
  submitter = 1;
  }
<?php /* END OF ADDED FOR CCGV */ ?>
function selectRowEffect(object, buttonSelect) {
 if (!selected) {
   if (document.getElementById) {
     selected = document.getElementById('defaultSelected');
   } else {
     selected = document.all['defaultSelected'];
   }
 }

 if (selected) selected.className = 'moduleRow';
 object.className = 'moduleRowSelected';
 selected = object;

// one button is not an array
 if (document.checkout_payment.payment[0]) {
   document.checkout_payment.payment[buttonSelect].checked=true;
 } else {
   document.checkout_payment.payment.checked=true;
 }
}

function rowOverEffect(object) {
 if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
 if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}
//--></script>
<?php echo $payment_modules->javascript_validation(); ?>
</head>
<body>

<?php require(DIR_WS_INCLUDES . 'page_start.php'); ?>


<!-- body_text //-->

   <td width="100%" valign="top"><?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) {
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo tep_output_string_protected($error['title']); ?></b></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBoxNotice">
         <tr class="infoBoxNoticeContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main" width="100%" valign="top"><?php echo tep_output_string_protected($error['error']); ?></td>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 }
?>
<?php //-----   BEGINNING OF ADDITION: MATC   -----// 
if($HTTP_GET_VARS['matcerror'] == 'true'){
?>
  <tr>
       <td><?php 
$matc_error_box_contents = array();
$matc_error_box_contents[] = array('text' => MATC_ERROR);
new errorBox($matc_error_box_contents);

?></td>
     </tr>
<?php } //-----   END OF ADDITION: MATC   -----// ?>

     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></b></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
               <td class="main" width="50%" valign="top"><?php echo TEXT_SELECTED_BILLING_DESTINATION; ?><br><br><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td>
               <td align="right" width="50%" valign="top"><table border="0" cellspacing="0" cellpadding="2">
                 <tr>
                   <td class="main" align="center" valign="top"><b><?php echo TITLE_BILLING_ADDRESS; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td>
                   <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
                   <td class="main" valign="top"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br>'); ?></td>
                   <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
                 </tr>
               </table></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></b></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="5" cellpadding="2">
<?php
 // ** GOOGLE CHECKOUT **
 // Skips Google checkout as a payment option on the payments page since that option
 // is provided in the checkout page

 $selection = $payment_modules->selection();
 for($i=0, $n=sizeof($selection); $i<$n; $i++) {
   if($selection[$i]['id'] == 'googlecheckout') {
     array_splice($selection, $i, 1);	
     break;   
   }
 }
 // ** END GOOGLE CHECKOUT **

 if (sizeof($selection) > 1) {
?>
             <tr>

               <td class="main" width="100%" valign="top" colspan="2"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></td>

             </tr>
<?php
 } else {
?>
             <tr>

               <td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></td>

             </tr>
<?php
 }

 $radio_buttons = 0;
 for ($i=0, $n=sizeof($selection); $i<$n; $i++) {

if(!$i==0) {
echo '<tr><td colspan="2" align="left" class="main"><strong>OR</strong></td></tr>';  
}


?>
             <tr>

               <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="5" class="checkoutpayment">
<?php
   if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
     echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
   } else {
     echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
   }
?>
                   <td class="main" align="left">


				<?php echo tep_draw_radio_field('payment', $selection[$i]['id'],($selection[$i]['id'] == $payment)); ?>
<?php /*
   if (sizeof($selection) > 1) {
     echo tep_draw_radio_field('payment', $selection[$i]['id'], $i==0);
   } else {
     echo tep_draw_hidden_field('payment', $selection[$i]['id']);
   }*/
?>
                   </td>
                   <td class="main" colspan="3" align="left" width="100%"><b><?php echo $selection[$i]['module']; ?></b></td>


                 </tr>
<?php
   if (isset($selection[$i]['error'])) {
?>
                 <tr>

                   <td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>

                 </tr>
<?php
   } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
?>
                 <tr>

                   <td colspan="4"><table border="0" cellspacing="0" cellpadding="2">
<?php
     for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>
                     <tr>

                       <td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>
                       <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                       <td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>

                     </tr>
<?php
     }
?>
                   </table></td>

                 </tr>
<?php
   }
?>
               </table></td>

             </tr>
<?php
   $radio_buttons++;
 }
?>
           </table></td>

         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 echo $order_total_modules->credit_selection();// CCGV
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', tep_sanitize_string($comments), '', false);  ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
//-----   BEGINNING OF ADDITION: MATC   -----// 
if(MATC_AT_CHECKOUT != 'false'){
require(DIR_WS_MODULES . 'matc.php');
}
//-----   END OF ADDITION: MATC   -----//
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main"><b><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td>
               <?php //-----   CHANGE IN ROW BELOW: MATC  - Added id="TheSubmitButton"   -----// ?>
               <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE,'id="TheSubmitButton"'); ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
             </tr>
           </table></td>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
               <td><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
             </tr>
           </table></td>
           <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
           <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
           <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
           <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
         </tr>
       </table></td>
     </tr>
   </table></form></td>
<!-- body_text_eof //-->

<?php require(DIR_WS_INCLUDES . 'page_end.php'); ?>

Posted

Search for

 

if ( ($selection[$i]['id']

 

And make the changes there.

 

HTH

 

G

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Posted

Search for

 

if ( ($selection[$i]['id']

 

And make the changes there.

 

HTH

 

G

 

hi, thanks for the reply but no luck, it didn't work with or without this code on the end.

 

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
<td class="main" align="right">
<?php

Posted

For a radio button selection, I would think that if there is only one choice available, that it should be preselected and made read-only, so the customer can't deselect it.

 

Basic radio button:

<input type="radio" name="field_name" value="val_to_return" />label

 

To make preselected, add selected="selected".

To make read-only, add readonly="readonly".

 

The osC code which outputs radio buttons ought to do this when there is only one choice. Does it? If there are multiple choices, ideally one should be preselected (that's how radio buttons are supposed to work in a User Interface: at all times, one and only one is selected).

Posted

For a radio button selection, I would think that if there is only one choice available, that it should be preselected and made read-only, so the customer can't deselect it.

 

Basic radio button:

<input type="radio" name="field_name" value="val_to_return" />label

 

To make preselected, add selected="selected".

To make read-only, add readonly="readonly".

 

The osC code which outputs radio buttons ought to do this when there is only one choice. Does it? If there are multiple choices, ideally one should be preselected (that's how radio buttons are supposed to work in a User Interface: at all times, one and only one is selected).

 

hi thanks for your answer,

yes there is only one payment choice on our site "sagepay credit/debit cards"

but it does not select it automatic you have to select the redio button

could you take a look at my code above and see how this can be solved and post the code for me please as i have very little knowledge with php

Posted

So what's going on here?

                    <td class="main" align="left">


                                       <?php echo tep_draw_radio_field('payment', $selection[$i]['id'],($selection[$i]['id'] == $payment)); ?>
<?php /*
   if (sizeof($selection) > 1) {
     echo tep_draw_radio_field('payment', $selection[$i]['id'], $i==0);
   } else {
     echo tep_draw_hidden_field('payment', $selection[$i]['id']);
   }*/
?>
                   </td>

You've commented out the section which hides the payment selection (hidden field) if there's only one choice, and inserted code ahead of that which draws the (in this case, only) choice as a radio button. Presumably, the code ($selection[$i]['id'] == $payment) is supposed to be setting "true" if it's the only selection available, but I don't see $payment being set anywhere!

 

Try this:

                    <td class="main" align="left">

<?php
   if (sizeof($selection) > 1) {
// multiple choices, first one ($i is 0) is preselected
     echo tep_draw_radio_field('payment', $selection[$i]['id'], $i==0);
   } else {
// only one choice: show the radio button, but preselected and don't let the user change it
//    echo tep_draw_hidden_field('payment', $selection[$i]['id']);
     echo tep_draw_radio_field('payment', $selection[$i]['id'], true, 'readonly="readonly"');
   }
?>
                   </td>

if you want to display the only payment choice, as pre-selected and unchangeable by the user.

 

Note that the third parameter "true" will apparently just give you CHECKED in the resulting HTML. You may have to change includes/functions/html_output.php's definition for function tep_draw_selection_field from

      $selection .= ' CHECKED';

to

      $selection .= ' checked="checked"';

for XHTML compatibility.

Posted

So what's going on here?

                    <td class="main" align="left">


                                       <?php echo tep_draw_radio_field('payment', $selection[$i]['id'],($selection[$i]['id'] == $payment)); ?>
<?php /*
   if (sizeof($selection) > 1) {
     echo tep_draw_radio_field('payment', $selection[$i]['id'], $i==0);
   } else {
     echo tep_draw_hidden_field('payment', $selection[$i]['id']);
   }*/
?>
                   </td>

You've commented out the section which hides the payment selection (hidden field) if there's only one choice, and inserted code ahead of that which draws the (in this case, only) choice as a radio button. Presumably, the code ($selection[$i]['id'] == $payment) is supposed to be setting "true" if it's the only selection available, but I don't see $payment being set anywhere!

 

Try this:

                    <td class="main" align="left">

<?php
   if (sizeof($selection) > 1) {
// multiple choices, first one ($i is 0) is preselected
     echo tep_draw_radio_field('payment', $selection[$i]['id'], $i==0);
   } else {
// only one choice: show the radio button, but preselected and don't let the user change it
//    echo tep_draw_hidden_field('payment', $selection[$i]['id']);
     echo tep_draw_radio_field('payment', $selection[$i]['id'], true, 'readonly="readonly"');
   }
?>
                   </td>

if you want to display the only payment choice, as pre-selected and unchangeable by the user.

 

Note that the third parameter "true" will apparently just give you CHECKED in the resulting HTML. You may have to change includes/functions/html_output.php's definition for function tep_draw_selection_field from

      $selection .= ' CHECKED';

to

      $selection .= ' checked="checked"';

for XHTML compatibility.

 

hi, yes that did the trick, all is working great

thanks for your input and time to reply. :thumbsup:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...