Firebase transferring data between pages












0















I am trying to make a sign-up page that has a two-page process for a firebase based website. The first HTML page takes the users info (Name, email, etc.), the second lets them set some more data. I am having a problem when it comes to getting the unique user ID I set for the first page, transferring it over to the second page, and allowing the user to update their node with more data.



So I am using two separate js files the first for sign up page 1 is:



    var usersRef = firebase.database().ref().child('PickUp').child('Users').push();

document.getElementById('mySubmit').addEventListener('click', submitForm);

function submitForm(e){

e.preventDefault();

var name = getInputVal('name');
var pass = getInputVal('password');
var email = getInputVal('emailfield2');
var address = getInputVal('addressfield');
var gender = getInputVal('gender');

createUser( name, pass, email, address, gender);
}

function getInputVal(id){
return document.getElementById(id).value;
}
function createUser(fullName, password, email, gender) {
usersRef.set({
fullname: fullName,
password: password,
email: email,
gender: gender,
karma: "5000",
})


The Second is:



      var usersRef = firebase.database().ref().child('PickUp').child('Users');
document.getElementById('mySubmit2').addEventListener('click', submitForm);
function submitForm(e){

e.preventDefault();

var base = getInputVal('base');
var basket = getInputVal('basket');
var soccer = getInputVal('soccer');
var tennis = getInputVal('tennis');
var volley = getInputVal('volley');

updateUser(base, basket, soccer, tennis, volley);
}

function updateUser(base, basket, soccer, tennis, volley) {
usersRef.update({
baseball: base,
basketball: basket,
tennis: tennis,
soccer: soccer,
volleyball: volley

});


I am simply trying to connect these two nodes, from two different html pages, from two different files and make it 1 node with all the information in it.



I can't seem to find any references, or ways to fix this, but if there is please send it over. Any help is always appreciated.



Thanks










share|improve this question





























    0















    I am trying to make a sign-up page that has a two-page process for a firebase based website. The first HTML page takes the users info (Name, email, etc.), the second lets them set some more data. I am having a problem when it comes to getting the unique user ID I set for the first page, transferring it over to the second page, and allowing the user to update their node with more data.



    So I am using two separate js files the first for sign up page 1 is:



        var usersRef = firebase.database().ref().child('PickUp').child('Users').push();

    document.getElementById('mySubmit').addEventListener('click', submitForm);

    function submitForm(e){

    e.preventDefault();

    var name = getInputVal('name');
    var pass = getInputVal('password');
    var email = getInputVal('emailfield2');
    var address = getInputVal('addressfield');
    var gender = getInputVal('gender');

    createUser( name, pass, email, address, gender);
    }

    function getInputVal(id){
    return document.getElementById(id).value;
    }
    function createUser(fullName, password, email, gender) {
    usersRef.set({
    fullname: fullName,
    password: password,
    email: email,
    gender: gender,
    karma: "5000",
    })


    The Second is:



          var usersRef = firebase.database().ref().child('PickUp').child('Users');
    document.getElementById('mySubmit2').addEventListener('click', submitForm);
    function submitForm(e){

    e.preventDefault();

    var base = getInputVal('base');
    var basket = getInputVal('basket');
    var soccer = getInputVal('soccer');
    var tennis = getInputVal('tennis');
    var volley = getInputVal('volley');

    updateUser(base, basket, soccer, tennis, volley);
    }

    function updateUser(base, basket, soccer, tennis, volley) {
    usersRef.update({
    baseball: base,
    basketball: basket,
    tennis: tennis,
    soccer: soccer,
    volleyball: volley

    });


    I am simply trying to connect these two nodes, from two different html pages, from two different files and make it 1 node with all the information in it.



    I can't seem to find any references, or ways to fix this, but if there is please send it over. Any help is always appreciated.



    Thanks










    share|improve this question



























      0












      0








      0








      I am trying to make a sign-up page that has a two-page process for a firebase based website. The first HTML page takes the users info (Name, email, etc.), the second lets them set some more data. I am having a problem when it comes to getting the unique user ID I set for the first page, transferring it over to the second page, and allowing the user to update their node with more data.



      So I am using two separate js files the first for sign up page 1 is:



          var usersRef = firebase.database().ref().child('PickUp').child('Users').push();

      document.getElementById('mySubmit').addEventListener('click', submitForm);

      function submitForm(e){

      e.preventDefault();

      var name = getInputVal('name');
      var pass = getInputVal('password');
      var email = getInputVal('emailfield2');
      var address = getInputVal('addressfield');
      var gender = getInputVal('gender');

      createUser( name, pass, email, address, gender);
      }

      function getInputVal(id){
      return document.getElementById(id).value;
      }
      function createUser(fullName, password, email, gender) {
      usersRef.set({
      fullname: fullName,
      password: password,
      email: email,
      gender: gender,
      karma: "5000",
      })


      The Second is:



            var usersRef = firebase.database().ref().child('PickUp').child('Users');
      document.getElementById('mySubmit2').addEventListener('click', submitForm);
      function submitForm(e){

      e.preventDefault();

      var base = getInputVal('base');
      var basket = getInputVal('basket');
      var soccer = getInputVal('soccer');
      var tennis = getInputVal('tennis');
      var volley = getInputVal('volley');

      updateUser(base, basket, soccer, tennis, volley);
      }

      function updateUser(base, basket, soccer, tennis, volley) {
      usersRef.update({
      baseball: base,
      basketball: basket,
      tennis: tennis,
      soccer: soccer,
      volleyball: volley

      });


      I am simply trying to connect these two nodes, from two different html pages, from two different files and make it 1 node with all the information in it.



      I can't seem to find any references, or ways to fix this, but if there is please send it over. Any help is always appreciated.



      Thanks










      share|improve this question
















      I am trying to make a sign-up page that has a two-page process for a firebase based website. The first HTML page takes the users info (Name, email, etc.), the second lets them set some more data. I am having a problem when it comes to getting the unique user ID I set for the first page, transferring it over to the second page, and allowing the user to update their node with more data.



      So I am using two separate js files the first for sign up page 1 is:



          var usersRef = firebase.database().ref().child('PickUp').child('Users').push();

      document.getElementById('mySubmit').addEventListener('click', submitForm);

      function submitForm(e){

      e.preventDefault();

      var name = getInputVal('name');
      var pass = getInputVal('password');
      var email = getInputVal('emailfield2');
      var address = getInputVal('addressfield');
      var gender = getInputVal('gender');

      createUser( name, pass, email, address, gender);
      }

      function getInputVal(id){
      return document.getElementById(id).value;
      }
      function createUser(fullName, password, email, gender) {
      usersRef.set({
      fullname: fullName,
      password: password,
      email: email,
      gender: gender,
      karma: "5000",
      })


      The Second is:



            var usersRef = firebase.database().ref().child('PickUp').child('Users');
      document.getElementById('mySubmit2').addEventListener('click', submitForm);
      function submitForm(e){

      e.preventDefault();

      var base = getInputVal('base');
      var basket = getInputVal('basket');
      var soccer = getInputVal('soccer');
      var tennis = getInputVal('tennis');
      var volley = getInputVal('volley');

      updateUser(base, basket, soccer, tennis, volley);
      }

      function updateUser(base, basket, soccer, tennis, volley) {
      usersRef.update({
      baseball: base,
      basketball: basket,
      tennis: tennis,
      soccer: soccer,
      volleyball: volley

      });


      I am simply trying to connect these two nodes, from two different html pages, from two different files and make it 1 node with all the information in it.



      I can't seem to find any references, or ways to fix this, but if there is please send it over. Any help is always appreciated.



      Thanks







      javascript firebase firebase-realtime-database






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 22:04







      A.Martin

















      asked Nov 24 '18 at 21:46









      A.MartinA.Martin

      92




      92
























          2 Answers
          2






          active

          oldest

          votes


















          0














          This can be a timing issue. It is possible that your second script invokes the userRef request 'too fast' for Firebase. What you can try to do is the following:



          TL;DR - delay the Firebase user query



            var usersRef;
          document.getElementById('mySubmit2').addEventListener('click', submitForm);
          function submitForm(e){

          e.preventDefault();

          var base = getInputVal('base');
          var basket = getInputVal('basket');
          var soccer = getInputVal('soccer');
          var tennis = getInputVal('tennis');
          var volley = getInputVal('volley');
          userRef = firebase.database().ref().child('PickUp').child('Users');
          updateUser(base, basket, soccer, tennis, volley);
          }

          function updateUser(base, basket, soccer, tennis, volley) {
          usersRef.update({
          baseball: base,
          basketball: basket,
          tennis: tennis,
          soccer: soccer,
          volleyball: volley

          });





          share|improve this answer































            0














            The .onAuthStateChanged() method included in the client side SDK - in your case, the JavaScript SDK, documented here is is how to do this. firebase.auth().currentUser.uid will populate with that info.






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462647%2ffirebase-transferring-data-between-pages%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              This can be a timing issue. It is possible that your second script invokes the userRef request 'too fast' for Firebase. What you can try to do is the following:



              TL;DR - delay the Firebase user query



                var usersRef;
              document.getElementById('mySubmit2').addEventListener('click', submitForm);
              function submitForm(e){

              e.preventDefault();

              var base = getInputVal('base');
              var basket = getInputVal('basket');
              var soccer = getInputVal('soccer');
              var tennis = getInputVal('tennis');
              var volley = getInputVal('volley');
              userRef = firebase.database().ref().child('PickUp').child('Users');
              updateUser(base, basket, soccer, tennis, volley);
              }

              function updateUser(base, basket, soccer, tennis, volley) {
              usersRef.update({
              baseball: base,
              basketball: basket,
              tennis: tennis,
              soccer: soccer,
              volleyball: volley

              });





              share|improve this answer




























                0














                This can be a timing issue. It is possible that your second script invokes the userRef request 'too fast' for Firebase. What you can try to do is the following:



                TL;DR - delay the Firebase user query



                  var usersRef;
                document.getElementById('mySubmit2').addEventListener('click', submitForm);
                function submitForm(e){

                e.preventDefault();

                var base = getInputVal('base');
                var basket = getInputVal('basket');
                var soccer = getInputVal('soccer');
                var tennis = getInputVal('tennis');
                var volley = getInputVal('volley');
                userRef = firebase.database().ref().child('PickUp').child('Users');
                updateUser(base, basket, soccer, tennis, volley);
                }

                function updateUser(base, basket, soccer, tennis, volley) {
                usersRef.update({
                baseball: base,
                basketball: basket,
                tennis: tennis,
                soccer: soccer,
                volleyball: volley

                });





                share|improve this answer


























                  0












                  0








                  0







                  This can be a timing issue. It is possible that your second script invokes the userRef request 'too fast' for Firebase. What you can try to do is the following:



                  TL;DR - delay the Firebase user query



                    var usersRef;
                  document.getElementById('mySubmit2').addEventListener('click', submitForm);
                  function submitForm(e){

                  e.preventDefault();

                  var base = getInputVal('base');
                  var basket = getInputVal('basket');
                  var soccer = getInputVal('soccer');
                  var tennis = getInputVal('tennis');
                  var volley = getInputVal('volley');
                  userRef = firebase.database().ref().child('PickUp').child('Users');
                  updateUser(base, basket, soccer, tennis, volley);
                  }

                  function updateUser(base, basket, soccer, tennis, volley) {
                  usersRef.update({
                  baseball: base,
                  basketball: basket,
                  tennis: tennis,
                  soccer: soccer,
                  volleyball: volley

                  });





                  share|improve this answer













                  This can be a timing issue. It is possible that your second script invokes the userRef request 'too fast' for Firebase. What you can try to do is the following:



                  TL;DR - delay the Firebase user query



                    var usersRef;
                  document.getElementById('mySubmit2').addEventListener('click', submitForm);
                  function submitForm(e){

                  e.preventDefault();

                  var base = getInputVal('base');
                  var basket = getInputVal('basket');
                  var soccer = getInputVal('soccer');
                  var tennis = getInputVal('tennis');
                  var volley = getInputVal('volley');
                  userRef = firebase.database().ref().child('PickUp').child('Users');
                  updateUser(base, basket, soccer, tennis, volley);
                  }

                  function updateUser(base, basket, soccer, tennis, volley) {
                  usersRef.update({
                  baseball: base,
                  basketball: basket,
                  tennis: tennis,
                  soccer: soccer,
                  volleyball: volley

                  });






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 24 '18 at 22:01









                  AviadAviad

                  1,3131914




                  1,3131914

























                      0














                      The .onAuthStateChanged() method included in the client side SDK - in your case, the JavaScript SDK, documented here is is how to do this. firebase.auth().currentUser.uid will populate with that info.






                      share|improve this answer




























                        0














                        The .onAuthStateChanged() method included in the client side SDK - in your case, the JavaScript SDK, documented here is is how to do this. firebase.auth().currentUser.uid will populate with that info.






                        share|improve this answer


























                          0












                          0








                          0







                          The .onAuthStateChanged() method included in the client side SDK - in your case, the JavaScript SDK, documented here is is how to do this. firebase.auth().currentUser.uid will populate with that info.






                          share|improve this answer













                          The .onAuthStateChanged() method included in the client side SDK - in your case, the JavaScript SDK, documented here is is how to do this. firebase.auth().currentUser.uid will populate with that info.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 24 '18 at 22:02









                          Ron RoystonRon Royston

                          6,34732643




                          6,34732643






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462647%2ffirebase-transferring-data-between-pages%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              404 Error Contact Form 7 ajax form submitting

                              How to know if a Active Directory user can login interactively

                              TypeError: fit_transform() missing 1 required positional argument: 'X'