Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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

share|improve this question
    
are you familiar with ajax? – khuderm 15 hours ago
    
Yes, but this functionality must be done in angularjs. As the entire application is in angularjs – rji rji 15 hours ago
    
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 – khuderm 15 hours ago

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);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.