
Mình không học về CNTT, chỉ là mình hay chia sẻ blog nên có về tò mò chút về lập trình wap/web để tiện lưu giữ và chia sẻ bài viết cho bạn bè. Mình đang muốn tạo 1 trang bằng js để trả lời tự động
Ví dụ:
+ thành viên chát: 18
+ bot: hai nghìn không trăm linh tư
Nhờ mọi người giúp mình viết 1 đoạn js mẫu để thực hiện phần này với ạ.
Đây là ảnh minh họa
[Ảnh 1, truy cập trang chưa nhập số liệu]

[Ảnh 2, đã nhập số liệu "18" và đưa ra kết quả "hai nghìn không trăm linh tư"]

Có thể else if (text == '18') {text = 'hai nghìn không trăm linh tư';}
cảm ơn mọi người đã đọc qua bài,mong được mọi người giúp đỡ
Ví dụ:
+ thành viên chát: 18
+ bot: hai nghìn không trăm linh tư
Nhờ mọi người giúp mình viết 1 đoạn js mẫu để thực hiện phần này với ạ.
Đây là ảnh minh họa
[Ảnh 1, truy cập trang chưa nhập số liệu]

[Ảnh 2, đã nhập số liệu "18" và đưa ra kết quả "hai nghìn không trăm linh tư"]

Có thể else if (text == '18') {text = 'hai nghìn không trăm linh tư';}
cảm ơn mọi người đã đọc qua bài,mong được mọi người giúp đỡ
Trống!
Trống!
- BBcode:
- Markdown:

<script>
const num2Word2 = function () {
var t = ["không", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín"],
r = function (r, n) {
var o = "",
a = Math.floor(r / 10),
e = r % 10;
return a > 1 ? (o = " " + t[a] + " mươi", 1 == e && (o += " mốt")) : 1 == a ? (o = " mười", 1 == e && (o += " một")) : n && e > 0 && (o = " lẻ"), 5 == e && a >= 1 ? o += " lăm" : 4 == e && a >= 1 ? o += " tư" : (e > 1 || 1 == e && 0 == a) && (o += " " + t[e]), o
},
n = function (n, o) {
var a = "",
e = Math.floor(n / 100),
n = n % 100;
return o || e > 0 ? (a = " " + t[e] + " trăm", a += r(n, !0)) : a = r(n, !1), a
},
o = function (t, r) {
var o = "",
a = Math.floor(t / 1e6),
t = t % 1e6;
a > 0 && (o = n(a, r) + " triệu", r = !0);
var e = Math.floor(t / 1e3),
t = t % 1e3;
return e > 0 && (o += n(e, r) + " ngàn", r = !0), t > 0 && (o += n(t, r)), o
};
return {
convert: function (r) {
if (0 == r) return t[0];
var n = "",
a = "";
do ty = r % 1e9, r = Math.floor(r / 1e9), n = r > 0 ? o(ty, !0) + a + n : o(ty, !1) + a + n, a = " tỷ"; while (r > 0);
return n.trim()
}
}
}();
function num2Word(num) {
return num2Word2.convert(num);
}
alert(num2Word(2004));
</script>

@Chan Hoang Bổ sung code của @tờ ròm cho giống yêu cầu hơn 
Đề mô :vhttps://spidersilk.w3spaces.com/tuoi-tom.html
P/s: chỉ bổ sung css và html và jquery để có hiệu ứng đẹp mắt hơn

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<div class="w3-container w3-margin">
<div class="w3-card-4">
<div class="w3-container">
<h2>Công cụ đoán năm sinh</h2>
</div>
<form id="age" class="w3-container w3-margin w3-padding">
<p><label>Nhập số tuổi:</label>
<p style="font-size: 10px;">Nếu nhập tuổi thì ra năm sinh và nếu nhập năm sinh thì ra tuổi =)) tóm lại, bạn tuổi tôm :v</p>
<input class="w3-input" type="number">
</p>
<button type="submit" class="w3-buton w3-white w3-border-light-grey w3-block">Xem kết quả</button>
</form>
<textarea class="w3-input" id="textbox" style="resize: none;display: none"></textarea>
</div>
</div>
<script>
const num2Word2 = function () {
var t = ["không", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín"],
r = function (r, n) {
var o = "",
a = Math.floor(r / 10),
e = r % 10;
return a > 1 ? (o = " " + t[a] + " mươi", 1 == e && (o += " mốt")) : 1 == a ? (o = " mười", 1 == e && (o += " một")) : n && e > 0 && (o = " lẻ"), 5 == e && a >= 1 ? o += " lăm" : 4 == e && a >= 1 ? o += " tư" : (e > 1 || 1 == e && 0 == a) && (o += " " + t[e]), o
},
n = function (n, o) {
var a = "",
e = Math.floor(n / 100),
n = n % 100;
return o || e > 0 ? (a = " " + t[e] + " trăm", a += r(n, !0)) : a = r(n, !1), a
},
o = function (t, r) {
var o = "",
a = Math.floor(t / 1e6),
t = t % 1e6;
a > 0 && (o = n(a, r) + " triệu", r = !0);
var e = Math.floor(t / 1e3),
t = t % 1e3;
return e > 0 && (o += n(e, r) + " ngàn", r = !0), t > 0 && (o += n(t, r)), o
};
return {
convert: function (r) {
if (0 == r) return t[0];
var n = "",
a = "";
do ty = r % 1e9, r = Math.floor(r / 1e9), n = r > 0 ? o(ty, !0) + a + n : o(ty, !1) + a + n, a = " tỷ"; while (r > 0);
return n.trim()
}
}
}();
function num2Word(num) {
return num2Word2.convert(num);
}
//alert(num2Word(2004));
const d = new Date();
let year = d.getFullYear();
var form = $("#age");
$(form).submit(function(){
var age = $('input').val();
age = num2Word(year - age);
$('#textbox').text(age);
$("#textbox").show(550).delay(10000).hide('fade-out');
event.preventDefault();
});
</script>
</body>
</html>
Đề mô :vhttps://spidersilk.w3spaces.com/tuoi-tom.html
P/s: chỉ bổ sung css và html và jquery để có hiệu ứng đẹp mắt hơn


Cảm ơn @tờ ròm @Trùm Phụ nhé!. Còn 1 vấn đề này nữa
Mình muốn tạo 1 file js bên dưới (giống của @tờ ròm )
Và tạo form ( @Trùm Phụ) gọi phần js ra thì làm thế nào ạ.
Mình muốn tạo 1 file js bên dưới (giống của @tờ ròm )
//BOT
$('#bot_btnCreate1').on('click',() => {
var text = Number($('#bot_txt').val());
if(text == '0') { text = '000';}
else if (text == 'Hi''hello','Hê ly','chào','Nĩ Hạo','xin chào','chào bạn') {text = 'Chào bạn';}
$('#bot_txt').val(text);
})
Và tạo form ( @Trùm Phụ) gọi phần js ra thì làm thế nào ạ.

@Chan Hoang <div id=""> với append js thôi a

Đây là ý tưởng tạo mục soi kết quả xổ số mỗi khi bảng kết quả xuất hiện lô câm đầu. Phần Js mình lấy bên trang kết quả rất là dài, mình muốn rút gọn nó nhưng cứ xóa đi 1 đoạn nhỏ là nó không hoạt động được.
@tờ ròm @Trùm Phụ đây là vấn đề của mình ạ
@tờ ròm @Trùm Phụ đây là vấn đề của mình ạ
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<script language="JavaScript">document.title = "Công cụ soi lô câm đầu hiệu quả"</script>
<div class="card-header"><b>Công cụ soi lô câm đầu hiệu quả</b> </div></br>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!--nhập vào-->
<span style="color: red"><b>Nhập đầu câm</b>: </span></br><input maxlength="1" type="text" id="Mainlocamdau_txtDan" style="text-align:center"></br></br>
<!--hiển thị-->
<table id="Mainlocamdau_Table" style="width:100%;">
<td style="width:20%;"><b><input type="submit" value="Kết quả" id="Mainlocamdau_btnCreate1"></b></td>
</table>
<td style="width:100%;"><textarea rows="2" cols="20" id="Mainlocamdau_txtDan1" style="font-size:Large;height:95px;width:99%;"></textarea></td>
<script>
function loaiso(){var list_number_all='00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99';var idtext=document.getElementById('dnn_ctr460_ViewLOAIDANDB_txtNumber');
var idloaidau=document.getElementById('iddau');var idloaiduoi=document.getElementById('idduoi');var idloaicham=document.getElementById('idcham');var idloaibo=document.getElementById('idbo');var idloaitong=document.getElementById('idtong');var idloaisochuan=document.getElementById('idloaiso');var idthemsochuan=document.getElementById('idthemso');if(idloaidau.value.endsWith(',')){idloaidau.value=idloaidau.value.substring(0,idloaidau.value.length-1);}
if(idloaiduoi.value.endsWith(',')){idloaiduoi.value=idloaiduoi.value.substring(0,idloaiduoi.value.length-1);}
if(idloaibo.value.endsWith(',')){idloaibo.value=idloaibo.value.substring(0,idloaibo.value.length-1);}
if(idloaitong.value.endsWith(',')){idloaitong.value=idloaitong.value.substring(0,idloaitong.value.length-1);}
if(idloaisochuan.value.endsWith(',')){idloaisochuan.value=idloaisochuan.value.substring(0,idloaisochuan.value.length-1);}
if(idloaisochuan.value.startsWith(',')){idloaisochuan.value=idloaisochuan.value.substring(1);}
if(idthemsochuan.value.endsWith(',')){idthemsochuan.value=idthemsochuan.value.substring(0,idthemsochuan.value.length-1);}
var stloai=list_number_all;var arraychuoi=myTrim(stloai).split(',');var arrayloaidau=myTrim(idloaidau.value).split(',');for(var i=0;i<arraychuoi.length;i++){for(var j=0;j<arrayloaidau.length;j++){if(arraychuoi[i][0]==arrayloaidau[j]){stloai=stloai.replace(arraychuoi[i]+',','');stloai=stloai.replace(arraychuoi[i],'');}}}
arraychuoi=myTrim(stloai).split(',');var arrayloaiduoi=myTrim(idloaiduoi.value).split(',');for(var i=0;i<arraychuoi.length;i++){for(var j=0;j<arrayloaiduoi.length;j++){if(arraychuoi[i][1]==arrayloaiduoi[j]){stloai=stloai.replace(arraychuoi[i]+',','');stloai=stloai.replace(arraychuoi[i],'');}}}
arraychuoi=myTrim(stloai).split(',');var arrayloaicham=myTrim(idloaicham.value).split(',');for(var i=0;i<arraychuoi.length;i++){for(var j=0;j<arrayloaicham.length;j++){if(arraychuoi[i][0]==arrayloaicham[j]||arraychuoi[i][1]==arrayloaicham[j]){stloai=stloai.replace(arraychuoi[i]+',','');stloai=stloai.replace(arraychuoi[i],'');}}}
arraychuoi=myTrim(stloai).split(',');var arrayloaitong=myTrim(idloaitong.value).split(',');for(var i=0;i<arraychuoi.length;i++){var tong=sumdigits(arraychuoi[i]);for(var j=0;j<arrayloaitong.length;j++){if(arrayloaitong[j].length>0){if(tong-arrayloaitong[j]==0||tong-arrayloaitong[j]==10){stloai=stloai.replace(arraychuoi[i]+',','');stloai=stloai.replace(arraychuoi[i],'');}}}}
var arrayloaibo=myTrim(idloaibo.value).split(',');for(var i=0;i<arrayloaibo.length;i++){if(myTrim(arrayloaibo[i])!=''&&myTrim(arrayloaibo[i]).length==2){var danbo=BOSO(arrayloaibo[i]);arraychuoi=myTrim(danbo).split(',');for(var j=0;j<arraychuoi.length;j++){if(myTrim(arraychuoi[j])!=''&&myTrim(arraychuoi[j]).length==2){stloai=stloai.replace(arraychuoi[j]+',','');stloai=stloai.replace(arraychuoi[j],'');}}}}
if(myTrim(idloaisochuan.value)!=''){arraychuoi=myTrim(idloaiso.value).split(',');for(var j=0;j<arraychuoi.length;j++){stloai=stloai.replace(arraychuoi[j]+',','');stloai=stloai.replace(arraychuoi[j],'');}}
if(myTrim(idthemsochuan.value)!=''){arraychuoi=myTrim(idthemsochuan.value).split(',');for(var j=0;j<arraychuoi.length;j++){if(myTrim(arraychuoi[j])!=''&&arraychuoi[j].length==2&&stloai.indexOf(arraychuoi[j])<0){stloai=stloai+','+arraychuoi[j];}}}
idtext.value=stloai;return false;}
//Lô câm đầu
$('#Mainlocamdau_btnCreate1').on('click',() => {
var text = Number($('#Mainlocamdau_txtDan').val());
if(text == '0') { text = '26 - 62';}
else if (text == '1') {text = '39 - 93';}
else if (text == '2') {text = '24 - 42';}
else if (text == '3') {text = '36 - 63';}
else if (text == '4') {text = '46 - 64';}
else if (text == '5') {text = '39 - 93';}
else if (text == '6') {text = '01 - 10';}
else if (text == '7') {text = '22 - 77';}
else if (text == '8') {text = '11 - 66';}
else if (text == '9') {text = '04 - 40';}
$('#Mainlocamdau_txtDan1').val(text);
})
</script>
</body>
</html>

Đoạn else if (text == '1') {text = '39 - 93';} là đầu câm và kết quả mỗi khi xuất hiện trong bảng kết quả xổ số
.ví dụ có câm đầu 1, người dùng chỉ cần nhập số 1, sẽ nhận được kết quả là 39-93
.ví dụ có câm đầu 1, người dùng chỉ cần nhập số 1, sẽ nhận được kết quả là 39-93
Bạn ko biết code à? Muốn gọn thì phải viết lại code chứ bạn xoá đi thì chạy kiểu gì?
Bạn ko biết code à? Muốn gọn thì phải viết lại code chứ bạn xoá đi thì chạy kiểu gì?

@supertroll mình không biết code. Thường mình sẽ lấy code về và dựa vào đó để thực hiện ý tưởng của mình

@Chan Hoang ý bạn là chatbot giống vậy hả :vhttps://spidersilk.w3spaces.com/chatbot.html
Thảo luận: 18 comments
Tiếng Việt
English
中文
Français
العربية
עברית
Русский
Українська
Bahasa Indonesia
हिंदी
日本語
ภาษาไทย