|
|
|
สอบถามปัญหา การแยกคำที่เป็นตัวเลขด้วย split แล้วเก็บ array ครับผม |
|
|
|
|
|
|
|
ลองดูครับ
Code (PHP)
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<div class="content">40|40|280|50</div>
$('.content').each(function() {
var mydata = $(this).text().split('|').join(" ");
$(this).text(mydata);
});
|
|
|
|
|
Date :
2019-10-09 11:43:34 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณนะครับ
ลองแล้วไม่ได้อะครับ มีวิธีอื่นอีกใหมครับผม
code ใหญ่ประมาณนี้ครับ
Code (PHP)
function merge_array(array1, array2) {
var result_array = [];
var arr = array1.concat(array2);
var len = arr.length;
var assoc = {};
while(len--) {
var item = arr[len];
if(!assoc[item])
{
result_array.unshift(item);
assoc[item] = true;
}
}
return result_array;
}
function post_ticket(OrderItemId,MemberName,MemberEmail,MemberMobile) {
var ItemDescription = [];
var ItemCode = [];
var Quantity = [];
var ItemCost = [];
var TotalPaid = [];
var TaxPaid = [];
var IsExtraItem = [];
var total_arr_extra_item_id = [];
var total_arr_extra_item_description = [];
var total_arr_extra_item_price_num = [];
var extra_item = {};
var extra_item_amount = [];
jQuery('#ticket > div').each(function( index ) {
var ticket = jQuery( this ).find('.valpass').html();
var price = jQuery( this ).find('.price').attr("data-price");
var extra_item_id = jQuery( this ).find('.ExtraItemID').val();
var extra_item_description = jQuery( this ).find('.ExtraItemDescription').val();
var extra_item_price_num = jQuery( this ).find('.ExtraItemPriceNum').val();
var ticket_id = jQuery( this ).find('.valpass').attr('id');
var description = jQuery( this ).find('.description').val();
var ticketpricemain = jQuery( this ).find('.ticketpricemain').val();
if(ticket != '0'){
ItemDescription.push( description );
ItemCode.push( ticket_id );
Quantity.push( ticket );
ItemCost.push( ticketpricemain );
TotalPaid.push( ticketpricemain * ticket );
TaxPaid.push( 0 );
IsExtraItem.push( false );
if(extra_item_id){
var arr_extra_item_id = extra_item_id.split('|');
var arr_extra_item_description = extra_item_description.split('|');
var arr_extra_item_price_num = extra_item_price_num.split("|");
total_arr_extra_item_id = merge_array(total_arr_extra_item_id,arr_extra_item_id);
total_arr_extra_item_description = merge_array(total_arr_extra_item_description,arr_extra_item_description);
total_arr_extra_item_price_num = merge_array(total_arr_extra_item_price_num,arr_extra_item_price_num);
extra_item_amount += parseInt(ticket);
}
}
});
if(total_arr_extra_item_id.length > 0) {
for (var i=0;i<total_arr_extra_item_id.length;i++) {
ItemDescription.push( total_arr_extra_item_description[i] );
ItemCode.push( total_arr_extra_item_id[i] );
Quantity.push( extra_item_amount );
ItemCost.push( total_arr_extra_item_price_num[i] );
TotalPaid.push( total_arr_extra_item_price_num[i] );
TaxPaid.push( 0 );
IsExtraItem.push( true );
}
}
|
ประวัติการแก้ไข 2019-10-09 12:24:47 2019-10-09 14:25:07
|
|
|
|
Date :
2019-10-09 12:20:48 |
By :
คำบัน |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|