简体   繁体   中英

How to save each and every form input button actions into json file using eihter javascript or jquery or angularjs?

I wanted to save my all form inputs, each and every button action(for ng-clicked and non-ng-clicked including file uploads/urls, etc ie whatever I click, those values should be stored in json file/object ie for all <input type="button"> in my case), with the given sample structure either using javascript or jquery or angularjs(the sample structure is provided in Fiddle ).Here I am getting the each action log at: console.log('User actions :', $scope.userActions); , but I need is the same action logs should be stored in a json file with the proper structure for my given all input types. How to achieve this ?

AngularJS supports two-way binding, which means you don't need to submit your data.

As I don't know enough about your specific use case I can't get it to fully function, but this should get you going:

Plunk

The main thing is that everything is stored in a scope variable (as JSON):

$scope.source = {
    'testingwizard' : 'TestingWizard',
   'firstTitle': 'First Title',
   'nextstep': 'Sub',
    'test': {
      'uploadedurl': '/...abc.html',
      'text': 'TEST'
      },
   'network':   
   {
     'layer0': 'TestValue0',
    'layer1': 'TestValue1',
    'layer2': 'TestValue2',
     'testdata': 'TESTDATA',
     'number': '10'
   },
   'yesname': 'yes',
   'Result': 'TestResult',
};

That is active as long as you are on that page, so you can do a $http put to a backend at any time (and have the values you expect).

PS: I've slightly changed the values in the Plunk (added new prefix) to prove that it's not the HTML providing the values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM