我有以下语法:
$("#orderbynumber").autocomplete(
{
source: "get_orders_by_order_number",
messages:
{
noResults: '',
results: function() {}
},
select: function( event, ui )
{
var selectedObj = ui.item;
alert(selectedObj.value);
//get prices
$.post('get_sku_prices', {data:selectedObj.value},function(result) {
$('input[name^="deliveryweek"]').val(result[0]);
});
}
});
警报返回,例如
order number: Customer Name
我想做的是从
10827: Massmart
中删除: Massmart
所以我想要一个新变量(例如)
selectedObj.value
然后,我可以将其作为订单号传递给
selectedobjectorder = 10827
函数。所以像这样:
$("#orderbynumber").autocomplete(
{
source: "get_orders_by_order_number",
messages:
{
noResults: '',
results: function() {}
},
select: function( event, ui )
{
var selectedObj = ui.item;
alert(selectedObj.value);
//how to finx this code...
var selectedobjectorder= anything before :(selectedObj.value);
alert(selectedobjectorder);
//get prices
$.post('get_sku_prices', {data:selectedobjectorder},function(result) {
$('input[name^="deliveryweek"]').val(result[0]);
});
}
});
一如既往的感谢。
最佳答案
JS parseInt()是您想要的。
var selectedobjectorder = parseInt(jQuery.trim(selectedObj.value));
关于javascript - javascript仅带回文本的特定部分(codeigniter和JQuery),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16462527/