Javascript 未定义不是一个函数:document.create元素
我收到systemUsername的错误“Uncaught TypeError:undefined不是函数”。我已经做了两个多小时了,我不明白这是怎么定义的Javascript 未定义不是一个函数:document.create元素,javascript,undefined,Javascript,Undefined,我收到systemUsername的错误“Uncaught TypeError:undefined不是函数”。我已经做了两个多小时了,我不明白这是怎么定义的 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 num
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);
函数systemUsername()
{
/*由第一部分组成
姓氏、街道地址、姓名中的字母字符;日期的数字
月份;以及提交时间的数字秒字段。例如:用户使用名称注册
Bernardo O'Higgins,地址:解放者街213号,2014年4月25日12:31:16。他的系统用户名为
OLB2516*/
var systemUsername=document.createElement(“systemUsername”);
var lastname=document.forms[“userinfo”][“famName”].value;
var Address=document.forms[“userinfo”][“Address”].value;
//var withNoDigits=地址。替换(/[0-9]/g');
var firstname=document.forms[“userinfo”][“firstname”].value;
var dateStamp=新日期();
var dayNum=dateStamp.getDate();
var Seconds=dateStamp.getSeconds();
如果(dayNum尝试此操作,请使用+
进行串联,而不是
alert("tempSU: " + tempSU);
而不是
alert("tempSU: ".tempSU);
演示:请详细说明您的问题。在提供的代码片段中没有调用systemUsername
。这个问题与文档有什么关系。createElement
?又是一个新帐户?您的问题是什么?使用三个不同的帐户询问?对不起,我是新来的,但错误是突出的我创建的systemUsername元素的setAttribute函数。这些不是我的问题?老实说?概念是一样的,“Bernardo O'Higgins
”将您连接到这些问题…这不会导致错误,它只会提醒未定义
。但有一个地方需要修复。我不明白,在将“.”更改为“+”后,它仍会向我抛出相同的未定义?@Teemu