我有这样的号码:
0065921922572
我将此值作为参数传递给 JavaScript 中的函数。
当我提醒数据时,它会显示:
65921922572
(去掉前面的00)
我试图将数字转换为字符串,但它仍然给我相同的值。
我应该怎么做才能得到正确的号码?
javascript中的函数:
//function that creates posts
var postHandler = function(postsJSON,ctr) {
$.each(postsJSON,function(i,post) {
ctr++;
var id = 'post-' + post.code;
//create the HTML
$('<div></div>')
.addClass('post')
.attr('id',id)
//generate the HTML
.html(ctr + ". <input type='checkbox' name='item" + ctr +
"' id='item" + ctr + "' value='" + post.code +"' onClick='countElem("+ ctr +
")'> <input type='hidden' name='tick"+ ctr +"' id='tick"+ ctr +"'>" + post.code +
" -- " + post.description + " <input type='button' name='del_item' id='del_item'" +
" class='but' style='margin-right:100px;' value='x' onclick='delProduct("+ post.code +")'>")
//inject into the container
.appendTo($('#posts'))
.hide()
.slideDown(250,function() {
if(i == 0) {
$.scrollTo($('div#' + id));
}
});
});
};
php中的函数:
function get_posts($start = 0, $number_of_posts = 300) {
$posts = array();
/* get the posts */
$query = "SELECT distinct(code), description FROM sales_order, outstanding
WHERE sales_order.id = outstanding.so_id AND sales_order.outstanding = 'Y'
AND outstanding.out_status = '' AND sales_order.status
NOT IN ('sta_deliver', 'otw_deliver', 'com_deliver', 'cancel') order by description asc LIMIT $start, $number_of_posts";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
//preg_match("/(.*)/",$row['description'],$matches);
//$row['description'] = strip_tags($matches[1]);
if($row['code'] != '')
{
$strnum = (string)($row['code']);
$row['code'] = $strnum;
}
$posts[] = $row;
}
/* return the posts in the JSON format */
return json_encode($posts);
}