|
 |
|
อยากทราบการบวกค่าที่ string ด้วย อย่างเช่นดึงข้อมูล จากฐานข้อมูลออกมาเป็น A012331 ต้องการบวก 1 |
|
 |
|
|
 |
 |
|
SELECT MID(column_name,2)+1 AS id FROM table_name;
|
 |
 |
 |
 |
Date :
2009-10-01 11:43:20 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเป็นการบวกรหว่าง TextBox อ่ะครับ
|
 |
 |
 |
 |
Date :
2009-10-01 11:58:41 |
By :
evekrub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แบบนี้ครับ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="th" xml:lang="th">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<title>calculate number</title>
<script type="text/javascript">
//<![CDATA[
function pad0(t,n){
var tx = String(t);
var s = tx.replace(/\D/,'');
s = Array(10).join('0')+s;
var i = (tx*1)+'';
var r = 0;
r = (i.length < n)?s.substr(s.length-n,n):i;
tx = (isNaN(r))?Array(n+1).join('0'):r;
return tx;
}
function f1(){
var t1 = document.box.t1.value;
var prefix = t1.substr(0,1);
var id = t1.substr(1)*1;
document.box.t2.value = prefix + pad0(id+1, 6);
}
//]]>
</script>
</head>
<body>
<form method="post" action="?" name="box">
<input type="text" name="t1" value="A012331" />
<input type="text" name="t2" value="" />
<input type="button" value="cal" onclick="f1();" />
</form>
</body>
</html>
|
 |
 |
 |
 |
Date :
2009-10-01 12:25:22 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2009-10-01 14:33:52 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|