0

I am trying to create a new user for my Parse database, but it is not working with forms and inputs. It only works if I hard code the value

<form>
  First Name: <input type="text" id="firstName" /> 
  <br><br>
  Last Name: <input type="text" id="lastName" /> 
  <br><br>
  E-Mail: <input type="text" id="email" /> 
  <br><br>
  Password: <input type="password" id="email" /> <br>
</form>
<br><br>
<input type="button" value="Sign Up" onclick="signUp();" />


<script type="text/javascript">
  Parse.initialize("xxxxxxxxx","xxxxxxxxxxx");

  function signUp() {

    var name = document.getElementById("firstName").value;
    var pass = document.getElementById("password").value;
    var mail = document.getElementById("email").value;

    var user = new Parse.User();
    user.set("username", name);
    user.set("password", pass);
    user.set("email", mail);

  }

when setting the user instance variables, it works if I hard code the string as I said before, like this:

  var user = new Parse.User();
  user.set("username", "bob");
  user.set("password", 1234);
  user.set("email", "[email protected]");

I believe that something is going wrong when I call getElementById().value but I am not sure

3
  • 1
    did you check the developer console if there is any error Commented Apr 19, 2015 at 16:31
  • I forgot about that! thank you. It gave me an error of Uncaught TypeError: Cannot read property 'value' of null When I tried to get the value of the password input Commented Apr 19, 2015 at 16:34
  • 1
    did you see that you have to change the id of password to password . you forgot to change it when copy and paste Commented Apr 19, 2015 at 16:36

1 Answer 1

4

You forgot to change the ID of your password input:

E-Mail: <input type="text" id="email" /> 
<br><br>
Password: <input type="password" id="email" /> <br>
                                      ^

You probably meant to write

Password: <input type="password" id="password" /> <br>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.