一、自动获取时间戳
new = new Date().getTime()+num;
二、截取时间戳
num = (+new Date()).toString().substr(5,10);
例:
<div class="mui-input-row">
<label>时间</label>
<input type="text" class="mui-input-clear" id="c-number" placeholder="时间">
</div>
<script>
new = new Date().getTime()+num;
$('#c-number').val(num);
</script>
三、自动生成12位数字
<div class="mui-input-row" style="height:56px;">
<label style="float:right;">
<button οnclick="javascript:generate();return false;">点击生成货号</button>
</label>
<input type="text" class="mui-input-clear" id="generateCom" readonly="readonly" placeholder="产品货号" style="width:51%;height:56px;">
</div>
<script>
function generate(){
for(var j=0;j<10;j++){
var randStr = "";
for (var i = 0; i < 12; i++) {//此处的12为生成12位数字,可随即更改
var randItem = Math.floor(Math.random() * 10);
randStr += randItem;
}
var value="Z766"+randStr;//此处的766是要求必须已766开头(此处可以更改)
document.getElementById("generateCom").value=(value);
}
}
</script>