Jump to content
  • Advertisement
Pedro Alves

problem select value colum

Recommended Posts

is working my selection a value of colum of the table and now is not working now is say undifined

<?php foreach ($servicos->getservicosempresa($d)as $r): ?>
           
            <tr>
           <!--tr-->
          <?php 
          if($r['quantidade']==0){
          ?>
              <td style="visibility:collapse" > <?php echo $r['id']; ?></td>
      			<td  style="background-color:#CC0000"><?php echo $r['nome']; ?>
      			</td>
                <td style="background-color:#CC0000"><?php echo $r['descricao']; ?>
                	</td>
                <td style="background-color:#CC0000"><?php echo $r['quantidade']; ?>
                	</td>
                <td style="background-color:#CC0000"><?php echo $r['precosiva']; ?></td>
                  <td style="background-color:#CC0000"><?php echo $r['taxa']; ?></td>
                    <td style="background-color:#CC0000"><?php echo $r['txt']; ?>
                    </td>
                     <td style="background-color:#CC0000"><?php echo $r['valordesc']; ?>
                     </td>
                    <td style="background-color:#CC0000"><?php echo $r['valoriva']; ?>
                    	</td>
                    <td style="background-color:#CC0000"><?php echo $r['precototal']; ?>
                    	</td>
                   
               <td style="visibility:hidden"> <button type="submit" class="btn">
      <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;Selecionar
      </button>
      </td>
      </tr>
          <?php
} else if($r['quantidade']<=5 & $r['quantidade']>0){?>
	
	 <td data-nome="<?php echo $r['id']; ?>" style="visibility:collapse"><?php echo $r['id'];?>  <input type="text" value="<?php echo $r['id'];?>"  style="visibility:hidden;width: 5px"  name="id" id="id"></td>
      			<td  style="background-color:#F5E79E"><?php echo $r['nome']; ?>
      			</td>
                <td style="background-color:#F5E79E"><?php echo $r['descricao']; ?>
                	</td>
                <td style="background-color:#F5E79E"><?php echo $r['quantidade']; ?>
                	</td>
                <td style="background-color:#F5E79E"><?php echo $r['precosiva']; ?></td>
                  <td style="background-color:#F5E79E"><?php echo $r['taxa']; ?></td>
                    <td style="background-color:#F5E79E"><?php echo $r['txt']; ?>
                    </td>
                     <td style="background-color:#F5E79E"><?php echo $r['valordesc']; ?>
                     </td>
                    <td style="background-color:#F5E79E"><?php echo $r['valoriva']; ?>
                    	</td>
                    <td style="background-color:#F5E79E"><?php echo $r['precototal']; ?>
                    	</td>
                   
               <td> <button type="submit" class="btn">
      <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;Selecionar
      </button>
      </td>
      </tr>
<?php	
}
else {?>
	<td  style="visibility:collapse"><?php echo $r['id']; ?><input  name="id" id="id" style="visibility:hidden;width: 5px" class="form-horizontal" type="text"></td>
      			<td ><?php echo $r['nome']; ?>
      			</td>
                <td><?php echo $r['descricao']; ?>
                	</td>
                <td><?php echo $r['quantidade']; ?>
                	</td>
                <td><?php echo $r['precosiva']; ?></td>
                  <td><?php echo $r['taxa']; ?></td>
                    <td><?php echo $r['txt']; ?>
                    </td>
                     <td><?php echo $r['valordesc']; ?>
                     </td>
                    <td><?php echo $r['valoriva']; ?>
                    	</td>
                    <td><?php echo $r['precototal']; ?>
                    	</td>
                   
               <td> <button type="submit" class="btn">
      <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;Selecionar
      </button>
      </td>
<?php }
          ?>
           
            </tr>
              <?php endforeach; ?>
        </tbody>
<script>
         $(function(){
    $(document).on('click', '.btn', function(e) {
        e.preventDefault;
        var nome = $(this).parent().parent().find('td').data('nome');
        $("input[name='id']").val(nome);
        alert(nome);
    });
});
 </script>

 

problem solve

my mistake

i forget put this in td data-nome="<?php echo $r['id'];?>"

Share this post


Link to post
Share on other sites
Advertisement

now i have other problem

when i try insert a new data the value descricao give undefined

but if update work fine

i dont know why is not working

<button class="btn btn-primary btn-o pull-right" data-toggle="modal" data-target=".bs-example-modal-lg">
														Novo Servico
													</button>
	
	<br>
	<div ng-app="sa_app" ng-controller="controller" ng-init="show_data()">
		
		
	<div class="modal fade bs-example-modal-lg"  tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
											<div class="modal-dialog modal-dialog modal-lg">
												<div class="modal-content">
													<div class="modal-header">
														<button type="button" class="close" data-dismiss="modal" aria-label="Close">
															<span aria-hidden="true">×</span>
														</button>
														
													</div>
													<div class="modal-body">
														 <ul class="nav nav-pills nav-justified" >
    <li  class="active"><a data-toggle="pill" href="#home">Dados</a></li>
    <li><a data-toggle="pill" href="#Descricao">Descricao</a></li>
    
  </ul>
		<div class="tab-content">
    <div id="home" class="tab-pane fade in active">												
	<label>Nome do Servico</label>
            <input type="text" name="nome" ng-model="nome" class="form-control">
            <br/>
           
            <label>Quantidade</label>

            <input type="text" name="quantidade" ng-model="quantidade" class="form-control">
            <br/>
			<label>Nome da Empresa</label>
		<select ng-init="show_data1()" class="form-control"  name="Nome" ng-model="Nome">
			 <option ng-repeat="x1 in names1" value={{x1.id}}>{{x1.Nome}}</option>
			 <option>Selecione Empresa</option>
        
</select>
        
            <br/>
			<label>Descontos</label>
			<select ng-init="show_descontos()" class="form-horizontal"  name="descontos" ng-model="descontos">
        	
		<option ng-repeat="desc in desco" value={{desc.id}}>{{desc.taxa}}</option>
		 <option>Selecione o Descontos</option>
</select>
			<label>IVA</label>
			<select ng-init="show_iva()" class="form-horizontal"  name="iva" ng-model="iva">
				
        <option ng-repeat="iva in ivas" value={{iva.id}}>{{iva.txt}}</option>
		 <option>Selecione Iva</option>
</select>
 <br/>
			<label>Preco Sem iva</label>
            <input type="text" name="precosiva" ng-model="precosiva" class="form-control">
            <br/>
			
            <input type="hidden" ng-model="id">
          
													</div>
													  <div id="Descricao" class="tab-pane">
													   <label>Descrição</label>
													   <!--textarea class="form-control ckeditor" cols="5" name="descricao" id="descricao" ng-model="descricao" rows="5"></textarea--> <!--Don´t Work give undefiend --->
                                                         <textarea class="form-control" cols="5" name="descricao" id="descricao" ng-model="descricao" rows="5"></textarea><!---Work -->
           
            <br/>
													  </div>
													</div>
													</div>
													<div class="modal-footer">
														<button type="button" class="btn btn-primary btn-o" data-dismiss="modal">
															Close
														</button>
														<button type="button" class="btn btn-primary" name="insert" ng-click="insert()" value="{{btnName}}" data-dismiss="modal">
															Save changes
														</button>
													</div>
												</div>
											</div>
										</div>
      <script>  
var app = angular.module("sa_app", ['ui.bootstrap']);
app.filter('startFrom', function() {
    return function(input, start) {
        if(input) {
            start = +start; //parse to int
            return input.slice(start);
        }
        return [];
    }
});
app.controller("controller", function($scope, $http,$timeout) {
    $scope.btnName = "Insert";
    $scope.insert = function() {
        if ($scope.nome == null) {
            alert("Insira o nome do Servico");
        } else if ($scope.descricao == null) {
          //  alert("Insira a descricao");
			alert($scope.descricao);
        } else if ($scope.quantidade == null) {
            alert("insira a quantidade");
			} else if ($scope.Nome == null) {
            alert("insira a Nome da Empresa");
			} else if ($scope.precosiva == null) {
            alert("insira a O Valor do Preço");
			} else if ($scope.descontos == null) {
            alert("insira a O Valor do Desconto");
			} else if ($scope.iva == null) {
            alert("insira a O Valor do IVA");
        } else {
            $http.post(
                "servicos/insert.php", {
                    'nome': $scope.nome,
                   
                    'quantidade': $scope.quantidade,
					 'Nome': $scope.Nome,
					  'precosiva': $scope.precosiva,
					   'descontos': $scope.descontos,
					    'iva': $scope.iva,
						 'descricao': $scope.descricao,
                    'btnName': $scope.btnName,
                    'id': $scope.id
                }
            ).success(function(data) {
                alert(data);
				
                $scope.nome = null;
                $scope.descricao = null;
                $scope.quantidade = null;
				$scope.Nome=null;
				 $scope.precosiva = null;
				 $scope.descontos = null;
				 $scope.iva = null;
                $scope.btnName = "Insert";
                $scope.show_data();
            });
        }
    }
    $scope.show_data = function() {
        $http.get("servicos/display.php")
            .success(function(data) {
                $scope.names = data;
				$scope.currentPage = 1;
			//current page
			$scope.entryLimit = 5;
			//max no of items to display in a page
			$scope.filteredItems = $scope.names.length;
			//Initially for no filter
			$scope.totalItems = $scope.names.length;
            });
    }
	$scope.show_data1 = function() {
        $http.get("servicos/display1.php")
            .success(function(data) {
                $scope.names1 = data;
            });
    }
	$scope.show_descontos = function() {
        $http.get("servicos/descontos.php")
            .success(function(data) {
                $scope.desco = data;
            });
    }
	
	$scope.show_iva = function() {
        $http.get("servicos/iva.php")
            .success(function(data) {
                $scope.ivas = data;
            });
    }
    $scope.update_data = function(id,nome,descricao,quantidade,Nome,precoiva,descontos,iva) {
	 
        $scope.id = id;
       $scope.nome = nome;
                $scope.descricao =descricao;
                $scope.quantidade = quantidade;
				$scope.Nome=Nome;
				 $scope.precosiva = precoiva;
				 $scope.descontos= descontos;
				 $scope.iva = iva;
        $scope.btnName = "Update";
    }
		$scope.setPage = function(pageNo) {
		$scope.currentPage = pageNo;
	};
	
	$scope.filter = function() {
		$timeout(function() {
			$scope.filteredItems = $scope.filtered.length;
		}, 10);
	};
	$scope.sort_by = function(predicate) {
		$scope.predicate = predicate;
		$scope.reverse = !$scope.reverse;
	};

     $scope.delete_data = function(id) {
        if (confirm("Are you sure you want to delete?")) {
            $http.post("servicos/delete.php", {
                    'id': id
                })
                .success(function(data) {
                   // alert(data);
                    $scope.show_data();
                });
        } else {
            return false;
        }
    }
});
</script>  

 

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!