How should I read the values of input fields to set them as

Posted by jsniemi79 on 20-Nov-2014 14:04

I am trying to save the user and password values on my app to eliminate typing.  My user is an input field with a text type and my password is an input field with the password type.

I am running the following javascript on value change of a toggle button that I added to my login screen.  My variables are both being logged currently as undefined.

var a = $(this).val();
var name = $('#usernameValue').val();
var pw = $('#passwordValue').val();

console.log(name);
console.log(pw);

if (a == 'on') {
localStorage.setItem("UserID",name);
localStorage.setItem("Password",pw);
} else {
localStorage.setItem("UserID",'');
localStorage.setItem("Password",'');
}

What is the correct syntax to return the on screen values of the my user and password input fields.

Posted by Roger Blanchard on 20-Nov-2014 14:13

Hmm, I use ‘Appery’.
 
For example,
 

var name = Appery('usernameValue').val();
var pw = Appery('passwordValue').val();

 
Roger Blanchard
Osprey Retail Systems, Inc.

All Replies

Posted by Roger Blanchard on 20-Nov-2014 14:13

Hmm, I use ‘Appery’.
 
For example,
 

var name = Appery('usernameValue').val();
var pw = Appery('passwordValue').val();

 
Roger Blanchard
Osprey Retail Systems, Inc.

Posted by jsniemi79 on 20-Nov-2014 14:29

That worked.  Thanks.  

Can anyone tell me what was wrong with my original code that it couldn't find those values?

This thread is closed