Stored value generating [object HTMLInputElement]

I have an indexedDB and using it for a login function. I'm trying to populate a form with the users information when they log in. However the form populates with [object HTMLInputElement] instead of the users info. This is where I take the user (db key) to access the Object (the user) EDITThis is my site where it's running: http://www3.carleton.ca/clubs/sissa/html5/admin.html My site editor is updating it as I save, so there may be changes to the site script as I try new things. This is where I take the user (db key) to access the Object (the user) function loginCheck(user,pass){ db.transaction("users").objectStore("users").get(user).onsuccess = function(event) { var loggedUser = event.target.result; if(!loggedUser){ alert('Sorry, Username does not exist. Please try again.'); }else if(pass !== loggedUser.pw ){ alert('Incorrect log in combination. Please try again.'); }else{loggedIn(loggedUser);} } } function loggedIn(loggedUser){ var u=loggedUser; alert('Welcome '+u.fn+' '+u.ln+' to Macroplay'); //function to populate fields alert('get values called'); getValues(u); //session store var signedin = 'user'; var username = u.userName; newLocal(signedin,username); alert('local storage set'); } I use this function getValues to store the various fields I want from the object. **EDIT: I declared the variable test as global and stored the users first name (fn). The alerts show the correct name but the populate still gives me undefined.** var test; function getValues(loggedUser){ var u = loggedUser; alert('storing first name'); test = u.fn; alert('First name = '+test); lName = u.ln; users = u.userName; pass = u.pw; email = u.em; dob = u.dob; tel = u.tel; bio = u.bio; school = u.scl; alert('user values stored'); if(u.gender == 'M'){ gender[0].checked= true ; }else{gender[1].checked= true ;} } This is the function I use to populate the form that's giving me [object HTMLInputElement] function populateFields(){ alert('Name of populated field: '+test); fName.value = test; lName.value = lName; users.value = users; pass.value = pass; email.value = email; dob.value = dob; tel.value = tel; bio.value = bio; terms.disabled = true; school.value = school; alert('populate fields done'); save.value = 'Update'; signin.innerHTML = 'Log Out'; registerLabel.innerHTML = 'Account Information'; //open user info form var accountInfo = document.getElementsByTagName('details'); accountInfo[1].open = open; }
Do not do authentication in client-side JavaScript. The code you posted shows me how to discover the passwords of every user in your database using nothing but a web browser. Authentication must be done on a server. There must exist no API that could return a user's password to client-side JavaScript.

以上就是Stored value generating [object HTMLInputElement]的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏