javascript - Stored value generating [object HTMLInputElement] -


I have an indexed DB and it is used for the login function. When users log in, I am trying to populate a form with user information. However, users are populated with the form [object HTMLInputElement] instead of information

This is where I take the user (DB key) to access the object (user) < P> Edit This is my site where it's running: My site editor is updating it as I save, so I can change the site script as trying new things.

This is where I take the user (DB key) to use the object (user)

  function login check (user, pass) {db. Transaction ("user"). ObjectStore ("Users"). Receive (user) .onsuccess = function (event) {var loggedUser = event.target.result; If (! LoggedUser) {Warning ('Sorry, user name does not exist, please try again.'); } And if (pass! == loggedUser.pw) {Warning ('wrong log combination, please try again.'); } Other {Log In (LogueAaster);}}} Function Login (Logueurs) {var u = loggedUser; Alert ('Welcome' + U.F.N + '' + U.L.N + 'Macroplay'); // to populate a field alert for a function (get 'value value'); GetValues ​​(U); // session store var signin = 'user'; Var Username = u.userName; NewLocal (signin, user name); Warning ('local storage set'); }   

I use this function getValues ​​to store different objects that I want from the object.

Edit: I declare the Variable Test globally and store the user's first name (FN) alerts show the correct names, but Populate still undefines me.

  var test; Function getValues ​​(log user) {var u = loggedUser; Warning ('First Name Stored'); Test = u.fn; Warning ('first name =' + test); LName = u.ln; User = u.userName; Pass = u.pw; Email = uem; Dob = u.dob; Tel = u.tel; Bio = u.bio; School = u.scl; Warning ('user value stored'); If (u.gender == 'm') {gender [0]. Checked = true; } {{HTML}} {  
 

This is a function that I use [object HTMLInputElement] code> function PopulateFields () {Warning ('Population Area Name:' + Exam); 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; Cautious ('populated area'); Save.value = 'Update'; Signin.innerHTML = 'Logout'; RegisterLabel.innerHTML = 'Account Information'; // Open user information form var accountiffo = document.getElementsByTagName ('description'); AccountInfo [1] .open = open; }

Just look at one line:

  Fname.value = fName   

You are setting the property of value to fName to fName .

Instead of creating many global variables, just use loggedUser populateFields () :

  fName.value = LoggedUser.fn;   

Edit: Viewing, I see the important bit you left. populateFields () page being reloaded after is being called, therefore, reloading the page of populateFields () Do not have access to any of the variables created before .

Because I'm helping you with homework, I just do not want to answer you on a silver plate. The trick is that the user data should be retrieved from the database and should be made available to populateFields () , or from within the function. You can make the user object as a global variable, but it may be better to pass it as a parameter.

You may also want to cancel form submission:

  document.getElementById ("Login Form"). Onsubmit = function (e) {e.preventDefault (); }   

and then simply call populateFields () directly to loggedIn () getValues ​​() .

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -