我有一个网站上有信用卡付款表格,我在其他非常类似的网站上使用过。我遇到的问题是,当页面加载时,会自动选择信用卡付款选项,通常会显示信用卡的下拉列表。但是,在此站点上,直到在显示为已选中的单选按钮上发生第二次单击时才会显示该列表。如果有人知道可能导致这种情况的任何信息,我将非常感激!如果您向购物车添加任何内容并查看购物车页面,则可以在www.seed-city.com
(NSFW)看到此问题。谢谢你的时间。
你可以在这里看到问题:
http://www.seed-city.com/index.php?option=com_virtuemart&page=shop.cart&add_id [] = 270&安培; qadd_270 = 10
我的代码是:
<div class="yagendoo_vm_checkout_credit_input">
<table>
<tr>
<td nowrap width="10%" align="left"><?php echo $VM_LANG->_('VM_CREDIT_CARD_TYPE'); ?>:</td>
<td>
<script language="Javascript" type="text/javascript"><!--
writeDynaList( 'class="inputbox" name="creditcard_code" size="1"',
orders, originalPos, originalPos, originalOrder );
//-->
</script>
<?php
$db_cc->reset();
$payment_class = $db_cc->f("payment_class");
$require_cvv_code = "YES";
if(file_exists(CLASSPATH."payment/$payment_class.php") && file_exists(CLASSPATH."payment/$payment_class.cfg.php")):
require_once(CLASSPATH."payment/$payment_class.php");
require_once(CLASSPATH."payment/$payment_class.cfg.php");
$_PAYMENT = new $payment_class();
if( defined( $_PAYMENT->payment_code.'_CHECK_CARD_CODE')):?>
<?php $require_cvv_code = strtoupper( constant($_PAYMENT->payment_code.'_CHECK_CARD_CODE'));?>
<?php endif;
endif;?>
</td>
</tr>
<tr valign="top">
<td nowrap width="10%" align="left">
<label for="order_payment_name">
<?php echo $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_NAMECARD') ?>:
</label>
</td>
<td>
<input type="text" class="inputbox" id="order_payment_name" name="order_payment_name" value="<?php if(!empty($_SESSION['ccdata']['order_payment_name'])) echo $_SESSION['ccdata']['order_payment_name'] ?>" autocomplete="off" />
</td>
</tr>
<tr valign="top">
<td nowrap width="10%" align="left">
<label for="order_payment_number"><?php echo $VM_LANG->_('PHPSHOP_CHECKOUT_CONF_PAYINFO_CCNUM') ?>:</label>
</td>
<td>
<input type="text" class="inputbox" id="order_payment_number" name="order_payment_number" value="<?php if(!empty($_SESSION['ccdata']['order_payment_number'])) echo $_SESSION['ccdata']['order_payment_number'] ?>" autocomplete="off" />
更多代码:
foreach( $cards as $code => $name ) {
$script .= "orders[".$i++."] = new Array( '".addslashes($db_cc->f("payment_method_name"))."','$code','$name' );\n";
}
}
$script .= "function changeCreditCardList() { \n";
$script .= "var selected_payment = null;
for (var i=0; i<document.adminForm.payment_method_id.length; i++)
if (document.adminForm.payment_method_id[i].checked)
selected_payment = document.adminForm.payment_method_id[i].id;\n";
$script .="changeDynaList('creditcard_code',orders,selected_payment, originalPos, originalOrder);\n";
$script .="}\n";
$script .="//-->\n";
$script .="</script>\n";
$script .= '<noscript>'.ps_html::selectList('creditcard_code', key($cards), $cards ).'</noscript>';
return $script;
}
}
答案 0 :(得分:0)
您有一个没有项目的选择:
<select class="inputbox" name="creditcard_code" size="1"> </select>
通过上面的脚本加载项目
/*<![CDATA[*/var originalOrder = '1';
var originalPos = 'payment_method_id_3';
var orders = new Array(); // array in the format [key,value,text]
orders[0] = new Array( 'payment_method_id_3','VISA','Visa' );
orders[1] = new Array( 'payment_method_id_3','MC','MasterCard' );
orders[2] = new Array( 'payment_method_id_3','jcb','JCB' );
orders[3] = new Array( 'payment_method_id_3','australian_bc','Australian Bankcard' );
orders[4] = new Array( 'payment_method_id_3','SWITCH','Maestro' );
function changeCreditCardList() {
var selected_payment = null;
for (var i=0; i<document.adminForm.payment_method_id.length; i++)
if (document.adminForm.payment_method_id[i].checked)
selected_payment = document.adminForm.payment_method_id[i].id;
op_changeDynaList('creditcard_code',orders,selected_payment, originalPos, originalOrder);
}/*]]>*/
我假设op_changeDynaList
函数应该用数组加载select
。似乎changeCreditCardList
可能是onchange
处理程序。
同样,这是应该在问题中的东西。但是,我没有看到第一次实际加载列表的位置。您可能需要在页面加载后手动调用其中一个函数(如changeCreditCardList
),而不是等待第一个事件被触发。