0
在以下代碼中,當管理員編輯訂單時,我在opencart的管理面板中顯示order_status。訂單狀態顯示非常好。jQuery:如何用新的元素替換元素,只顯示新元素?
<?php if ($info_data['order_status']) { ?>
<tr>
<td><?php echo $info_data['text_order_status'];?</td>
<td id="order-status"><?php echo $info_data['order_status']; ?></td>
</tr>
<?php } ?>
但是,當管理員通過從下拉列表中選擇更新ORDER_STATUS它顯示與舊ORDER_STATUS更新ORDER_STATUS。我只需要顯示更新的order_status,我怎樣才能用更新的order_status替換舊的狀態?
if (json['success']) {
$('#history').load('index.php?route=sale/order/history&token=<?php echo $token; ?>&order_id=<?php echo $order_id; ?>&shipping_code=<?php echo $shipping_code; ?>');
$('#history').before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
$('textarea[name=\'comment\']').val('');
$('#order_tracking_number').val('');
$('#order-status').html($('select[name=\'order_status_id\'] option:selected').text());
}
我想這行應該做替換,但它不能正常工作,應該改變什麼?請幫忙 !
$('#order-status').html($('select[name=\'order_status_id\'] option:selected').text());
UPDATE: 代碼選擇框
<div class="form-group">
<label class="col-sm-2 control-label"
for="input-order-status"><?php echo $info_data['entry_order_status']; ?></label>
<div class="col-sm-10">
<select name="order_status_id" id="input-order-status" class="form-control">
<?php foreach ($info_data['order_statuses'] as $order_statuses) { ?>
<?php if ($order_statuses['order_status_id'] == $info_data['order_status_id']) { ?>
<option value="<?php echo $order_statuses['order_status_id']; ?>"
selected="selected"><?php echo $order_statuses['name']; ?></option>
<?php } else { ?>
<option
value="<?php echo $order_statuses['order_status_id']; ?>"><?php echo $order_statuses['name']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
你迭代這個部分? '<?PHP如果($ info_data [ 'ORDER_STATUS']){?>
如果您有多個''td id =「order-status」>'那麼您不應該使用'ID',您應該使用'class'來代替。 –
no sir這部分沒有迭代,它只驗證是否啓用了order_status, 和我只有一個
回答
試試這個:
來自:
到:
,如果你想與NAME的通話您選擇框,然後改變它
到:
來源
2016-10-08 00:34:08
它工作得很好,謝謝先生! – Haroon
用名稱調用selectbox不起作用先生,但通過id調用工程 – Haroon
現在應該工作 –
相關問題