0

I have a form in which on click of button input fields get appended. The form is as below.

<body data-ng-app="myApp" data-ng-controller="myController" >
<form name="educdetailsform" novalidate>
   <label>Education Details</label></br>
    <button ng-click="addfield()">Add Education</button>
     <div ng-repeat="item in items">
     <input type="text" name="qualification[]" data-ng-model="empData.qualification[]" placeholder="Qualification">
      <input type="text" name="year[]" data-ng-model="empData.year[]" placeholder="Year of Passing">
      <input type="text" name="percentage[]" data-ng-model="empData.percentage[]" placeholder="Percentage">
     </div> 
   <input type="submit" name="submit" ng-click="saveUser()" />
  </form>
</body>

The angular JS code for appending input fields is as follows

 var module=angular.module('myApp',[]);
 module.controller('myController',function($scope, $http){
  $scope.items = [{}];

$scope.addfield = function(){
   $scope.items.push({});
}

 });

This is the code and functionality http://jsfiddle.net/b0jtqzpj/2/

How to get the fields to saveUser() function and then save the data into database table using PHP Like, if the user has entered 3 entries i.e, the first entry must be saved in a row and 2nd entry in next row and 3rd entry in 3rd row. i.e, if 3 entries are entered in html form and submitted, 3 entries must be created in database table.

How do I catch data in angularjs saveUser() function and then save in database using PHP

3
  • are you familiar with ajax? Commented Dec 18, 2015 at 6:13
  • Yes, but this functionality must be done in angularjs. As the entire application is in angularjs Commented Dec 18, 2015 at 6:24
  • angularjs is a framework not a language. Notice the JS at the end which stands for JavaScript. Is there a reason why everything have to be written using angularjs? if so, check out this link. tutorials.jenkov.com/angularjs/ajax.html Commented Dec 18, 2015 at 6:29

1 Answer 1

0

You can check js fiddle http://jsfiddle.net/ss5yo9xk/4/ for making ajax call and you need to use below code at php side to get post data :

$postData = json_decode(file_get_contents('php://input'), true);
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.