我收到此错误' Uncaught TypeError:undefined不是函数'对于systemUsername。我现在已经在这里工作了2个多小时,我不明白这是怎么定义的?
function systemUsername()
{
/*consists of the first
alphabetic characters found in the Family name, street address, Given name; the numerical day of the
month; and the numerical seconds field of the time of submission. E.g.: A user registers with name
Bernardo O’Higgins, address 213 Liberator St, at 12:31:16 on 25 April 2014. His system username is
OLB2516*/
var systemUsername = document.createElement("systemUsername");
var lastname = document.forms["userinfo"]["famName"].value;
var Address = document.forms["userinfo"]["address"].value;
//var withNoDigits = address.replace(/[0-9]/g, '');
var firstname = document.forms["userinfo"]["firstName"].value;
var dateStamp = new Date();
var dayNum = dateStamp.getDate();
var Seconds = dateStamp.getSeconds();
if (dayNum<10)
{
var x = '0';
dayNum = x + dayNum;
}
alert(dayNum);
if (Seconds<10)
{
var x = '0';
Seconds = x + Seconds;
}
alert(Seconds);
var tempSU = lastname.charAt(0)+Address.charAt(0)+firstname.charAt(0)+dayNum.charAt(0)+dayNum.charAt(1)+Seconds.charAt(0)+Seconds.charAt(1);
systemUsername.setAttribute("type", "hidden");
systemUsername.setAttribute("name", "systemName");
systemUsername.setAttribute("value", "tempSU");
document.getElementById("userinfo").appendChild(systemUsername);
alert("tempSU: ".tempSU);
}
答案 0 :(得分:0)
试试这个,使用+
进行连接而不是.
alert("tempSU: " + tempSU);
而不是
alert("tempSU: ".tempSU);