• Viết bài chia sẻ trên Vsfan.vn nhận Donate dưới 1 TỶ ĐỒNG Xem chi tiết

Fix lỗi Cannot read property 'toUpperCase' of undefined (line 23, file "Code") của script.google.com

tbttkc

Lớp mầm
Thành viên
mọi người giúp e với, e làm form login nhưng khi chạy thử ( vào Run chọn function chọncheck login) bị lỗi này ạ, mong mn giúp đỡ
hỏi1.PNG
hỏi 2.PNG
em
 

___Trang_Miu___

Mod & Support
Hỗ trợ về ROM, Root
Thành viên
mọi người giúp e với, e làm form login nhưng khi chạy thử ( vào Run chọn function chọncheck login) bị lỗi này ạ, mong mn giúp đỡ Xem đính kèm 4465Xem đính kèm 4466 em
Tạo web còn dễ chứ tạo forum đăng nhập được và thành viên thì bạn phải rành về mảng công nghệ thông tin nhé chứ có hướng dẫn thì bạn cũng không hiểu đâu vì mấy cái này nó lằng nhằng lắm khi
 

Duck

Lớp lá
Thành viên
có thể getValue không trả về string nên không dùng touppercase được. nhét thêm tostring() rồi mới touppercase() vô thử.
 

tbttkc

Lớp mầm
Thành viên
có thể getValue không trả về string nên không dùng touppercase được. nhét thêm tostring() rồi mới touppercase() vô thử.
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('code');
}
function AddRecord(firstname, lastname, address, city, state, zip) {
var url = ' //https://docs.google.com/spreadsheets/d/1_Yu5dD-f6Fb73-hUGfaAnIyemB0yMKCKIBN9LxjEr0o/edit?usp=sharing
var ss= SpreadsheetApp.openByUrl(url);
var webAppSheet = ss.getSheetByName("DATA");
webAppSheet.appendRow([firstname, lastname, address, city, state, zip, new Date()]);

}
function checkLogin(username, password) {
var url = ' //https://docs.google.com/spreadsheets/d/1_Yu5dD-f6Fb73-hUGfaAnIyemB0yMKCKIBN9LxjEr0o/edit?usp=sharing
var ss= SpreadsheetApp.openByUrl(url);
var webAppSheet = ss.getSheetByName("USERNAMES");
var getLastRow = webAppSheet.getLastRow();
var found_record = '';
for(var i = 1; i <= getLastRow; i++)
{
if(webAppSheet.getRange(i, 1).getValue().toUpperCase() == username.toUpperCase() &&
webAppSheet.getRange(i, 2).getValue().toUpperCase() == password.toUpperCase())
{
found_record = 'TRUE';
}
}
if(found_record == '')
{
found_record = 'FALSE';
}

return found_record;

}
code đấy ạ
Bác sửa giúp e với
 

Duck

Lớp lá
Thành viên
Sửa dòng này
JavaScript:
if(webAppSheet.getRange(i, 1).getValue().toUpperCase() == username.toUpperCase() && webAppSheet.getRange(i, 2).getValue().toUpperCase() == password.toUpperCase())
thành
JavaScript:
if(webAppSheet.getRange(i, 1).getValue().toString().toUpperCase() == username.toUpperCase() && webAppSheet.getRange(i, 2).getValue().toString().toUpperCase() == password.toUpperCase())
hoặc
JavaScript:
if(String(webAppSheet.getRange(i, 1).getValue()).toUpperCase() == username.toUpperCase() && String(webAppSheet.getRange(i, 2).getValue()).toUpperCase() == password.toUpperCase())
 

SÔI ĐỘNG TRONG TUẦN

THEO DÕI Vsfan.vn TRÊN FB

Top