dylan dylan - 2 years ago 63
HTML Question

How do you get user input for a mongo db document from multiple different html pages?

I have a mongodb setup that will hold some user input values. The forms where the user will input data are all on different html pages, once you fill out one, it will send you to the next page. What I cannot figure out is how to put all this data into one document once every field has been filled. I find this complicated because if you go to the next page for the next form, that previous form will not just hold the data waiting for all the other forms to be filled out. To put this in some context, I am using meteor and the packages aldeed:autoform and aldeed:collection2 to have user input transformed into a json format document. At the moment, I can only have all the user input filled out on the same page using autoform then press the submit button for it all to be put on a document at the same time.

Answer Source

On the first form insert to a collection with the Meteor.userId() (assuming your users are logged in). On the next forms you can simply update the collection using methods.




  'firstForm': function (var1,var2) {
      createdBy: Meteor.userId(),
      var1: var1,
      var2: var2
  'secondForm': function (var3,var4) {
      createdBy: Meteor.userId()
    }, {
        $set: {
            var3: var3,
            var4: var4
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download