dongzhuo3376 2014-08-27 20:53
浏览 31

将选择框更改为自动完成jquery源php echo

Need your help

I want change select box with autocomplete jquery here my worked select box

<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>

and here my code for 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
}); 

});

but it won't work, please help me out.

I check on php file

  * 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

should I need to change

      $content .= 
      '<option value="'.$iShipping.';'.$iPayment.';'.$fShippingPaymentPrice.'">'.
        $aData['sName'].' : Rp. '.
        displayPrice( $fShippingPaymentPrice )
      .'</option>';

to be read as autocomplete source? please help how to change that.

Really thanks for your answer.

  • 写回答

1条回答 默认 最新

  • dongtiannan0367 2014-08-27 21:02
    关注

    Methinks you need to wrap your php echo output in quotation marks:

    //autocomplete
    $(".auto").autocomplete({
    source: <?php echo '"' . $sShippingPaymentSelect . '"'; ?>,
    minLength: 1
    }); 
    

    But without a description of "it wont work", we can't help you much further.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题