How should I read the values of input fields to set them as local storage variables? - Forum - Mobile - Progress Community

How should I read the values of input fields to set them as local storage variables?

 Forum

How should I read the values of input fields to set them as local storage variables?

This question is answered

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.

Verified Answer
  • Hmm, I use ‘Appery’.
     
    For example,
     

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

     
    Roger Blanchard
    Osprey Retail Systems, Inc.
All Replies
  • Hmm, I use ‘Appery’.
     
    For example,
     

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

     
    Roger Blanchard
    Osprey Retail Systems, Inc.
  • That worked.  Thanks.  

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