需要你的帮助
我想要使用自动完成jquery的更改选择框 在这里我的工作选择框
<select name="sShippingPayment" title="simple;<?php echo $lang['Select_shipping_and_payment']; ?>" onchange="countShippingPrice( this )" id="oShippingPayment">
<option value=""><?php echo $lang['Select']; ?></option>
<?php echo $sShippingPaymentSelect; ?>
</select>
这里是我的jquery代码
<form action='' method='post'>
<p><label>Shipping & Payment:</label><input type='text' name='sShippingPayment' value='' class='auto'></p>
</form>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
//autocomplete
$(".auto").autocomplete({
source: <?php echo $sShippingPaymentSelect; ?>,
minLength: 1
});
});
但它不起作用,请帮帮我。
我检查php文件
* Returns shipping and payment select
* @return string
*/
public function throwShippingPaymentsSelect( ){
$aShipping = $this->throwPaymentsShipping( 2 );
$aPayments = $this->throwPaymentsShipping( 1 );
if( isset( $aShipping ) && isset( $aPayments ) ){
$content = null;
foreach( $aShipping as $iShipping => $aData ){
if( isset( $aData['aPayments'] ) ){
foreach( $aData['aPayments'] as $iPayment => $sPriceModify ){
if( isset( $aPayments[$iPayment] ) ){
$fShippingPaymentPrice = !empty( $sPriceModify ) ? generatePrice( $aData['fPrice'], $sPriceModify ) : $aData['fPrice'];
$content .=
'<option value="'.$iShipping.';'.$iPayment.';'.$fShippingPaymentPrice.'">'.
$aData['sName'].' : Rp. '.
displayPrice( $fShippingPaymentPrice )
.'</option>';
}
} // end foreach
}
} // end foreach
return $content;
}
} // end function throwShippingPaymentsSelect
我应该更改
吗? $content .=
'<option value="'.$iShipping.';'.$iPayment.';'.$fShippingPaymentPrice.'">'.
$aData['sName'].' : Rp. '.
displayPrice( $fShippingPaymentPrice )
.'</option>';
被读作自动完成源?请帮助如何改变它。
非常感谢你的回答。
答案 0 :(得分:1)
您需要将php echo输出用引号括起来:
//autocomplete
$(".auto").autocomplete({
source: <?php echo '"' . $sShippingPaymentSelect . '"'; ?>,
minLength: 1
});
但如果没有“它不会起作用”的描述,我们就无法帮助你了。