javascript - onClick new input box add not working angularJs issue -


i want add dynamic form fields in database using php. have used angular add dynamic form fields. thing when trying insert data database last form field inserting in database. so, used array , loop increment , update form field database. somehow query not working , data not inserting database. can tell me wrong here? stuck. please help. thanx in advance.

here code:

    <form method="post">     <div class="form-group " >         <input type="text" placeholder="campaign name" class="form-control c-square c-theme input-lg" name="camp_name"> </div>         <div class="row col-md-12">             <div class="form-group col-md-6">start date                 <input type="date" placeholder="start date" class="form-control c-square c-theme input-lg" name="start_date">             </div>             <div class="form-group col-md-6">end date                 <input type="date" placeholder="end date" class="form-control c-square c-theme input-lg" name="end_date"> </div>             </div>          <div class="row col-md-12">             <div class="form-group">                 <label for="inputpassword3" class="col-md-8 control-label">select store</label>                 <div class="col-md-6 c-margin-b-20">                     <select class="form-control  c-square c-border-2px c-theme" multiple="multiple"  name="store">                         <option value="1">all stores</option>                         <option value="2">phoenix mall</option>                         <option value="3">1mg mall</option>                         <option value="4">orion mall</option>                      </select>                 </div>             </div>             </div>              <div class="row col-md-12" ng-app="angularjs-starter" ng-controller="mainctrl">                 <fieldset  data-ng-repeat="choice in choices">                     <label for="inputpassword3" class="col-md-1 control-label">elements</label>                     <div class="form-group col-md-3 ">                         <input type="text" placeholder="campaign name" ng-model="choice.name" class="form-control c-square c-theme input-lg" name="ele">                      </div>                     <label for="inputpassword3" class="col-md-1 control-label">quantity</label>                     <div class="form-group col-md-3" >                         <select class="form-control  c-square c-border-2px c-theme"  name="store">                             <option value="1">all stores</option>                             <option value="2">phoenix mall</option>                             <option value="3">1mg mall</option>                             <option value="4">orion mall</option>                          </select>                     </div>                      <button  class="btn c-theme-btn c-btn-uppercase btn-lg c-btn-bold c-btn-square" ng-click="addnewchoice()" >add</button>                     <button   ng-show="$last" ng-click="removechoice()" class="btn c-theme-btn c-btn-uppercase btn-lg c-btn-bold c-btn-square" >remove</button>                     </fieldset>               </div>            </div>     </div>     <div class="form-group">         <input type="text" placeholder="description" class="form-control c-square c-theme input-lg" name="description">     </div>     <input class="btn c-theme-btn c-btn-uppercase btn-lg c-btn-bold c-btn-square" value="submit" type="submit">  </form>    // angular script  <script type="text/javascript"> var app = angular.module('angularjs-starter', []);  app.controller('mainctrl', function($scope) {  $scope.choices = [{id: 'choice1'}, {id: 'choice2'}];  $scope.addnewchoice = function() {     var newitemno = $scope.choices.length+1;     $scope.choices.push({'id':'choice'+newitemno}); };  $scope.removechoice = function() {     var lastitem = $scope.choices.length-1;     $scope.choices.splice(lastitem); };  }); </script> 

what can take input type , put type="button". won't refresh page. not specifying type that's why taking type="submit" , whole page reloading. avoid this.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -