Undefined不是一个函数:document.创建元素
undefined is not a function : document.create element
我得到这个错误'未捕获的TypeError:未定义的不是一个函数'为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);
}
试试这个,用+
代替.
进行连接
alert("tempSU: " + tempSU);
代替
alert("tempSU: ".tempSU);
演示:http://jsfiddle.net/5yXAL/
相关文章:
- 停止对document.ready函数的重定向/刷新
- document.title函数可以't设置它与php一起工作
- 从Document调用onchange函数.已准备好从更新中预先选择的项目
- 函数从$(document).ready外部调用在$(document).ready中定义的函数
- 如果没有document.ready(),我怎么能拥有多个javascript函数呢
- 重载像$(document).ready这样的函数是错误的
- 如何在使用函数document.write()打印最终结果后,使用Javascript滚动到页面顶部
- $(document)中的多个javascript函数.ready不工作
- JavaScript执行从函数声明开始,而不是从$(document).ready()开始
- document.querySelectorAll() 函数不适用于所有元素
- 调用 Document.ready 外部的 AJAX 函数
- 未捕获的类型错误:document.getElementById(..).value.trigger不是函数
- 无法运行php函数来使用document.write更新db值
- JavaScript's替换与document.create()结合的函数-这个代码是做什么的
- 函数在例如$(document).ready()上注册时的通知
- javascript函数与document.querySelectorAll加filter()可以'工作不正常
- 如何在document.ready(function)时运行隐藏函数和动画
- mootools document.getelement不是函数
- Undefined不是一个函数:document.创建元素
- Android javascript注入,我如何调用这个函数$(document).ready(function(){…