Clauses and message JS

0

I need that when $DsTpVeiculo is Horse Truck input is filled out and shows a message asking to fill, and if it is Truck or Bitruck it should not be filled with a message as well. Any message in JS.

Code:

<?php  
   if($DsTpVeiculo == 'Cavalo Truck'){ ?>
    <td><input type="text" id="carreta" name="NrPlacaCarreta" value="<?php echo $NrPlacaCarreta; ?>"/></td>
<?php 
   }elseif($DsTpVeiculo == 'Bitruck' || $DsTpVeiculo == 'Truck'){ ?>
    <td><input type="text" id="carreta" name="NrPlacaCarreta" value="<?php echo $NrPlacaCarreta; ?>"/></td>
<?php
   }
?>
    
asked by anonymous 14.07.2016 / 14:51

2 answers

0

When it is truck or bitruck, disable the input using the message you can use alert (), more or less like this.

if($DsTpVeiculo == 'Bitruck' || $DsTpVeiculo == 'Truck'){ 

    echo '<script type="text/javascript">alert("Mensagem!");</script>';
?>
    <td><input disabled="true" type="text" id="carreta" name="NrPlacaCarreta" value="<?php echo $NrPlacaCarreta; ?>"/></td>
    
14.07.2016 / 15:04
0

You can solve your problem like this:

    <?php  
        $DsTpVeiculo = "Cavalo Truck";

        if($DsTpVeiculo == 'Cavalo Truck'){ 
            $NrPlacaCarreta = "Meu preenchimento de input;";
    ?>
    <td><input type="text" id="carreta" name="NrPlacaCarreta" value="<?php echo $NrPlacaCarreta; ?>"/></td>
    <?php 
       }elseif($DsTpVeiculo == 'Bitruck' || $DsTpVeiculo == 'Truck'){ 
            $NrPlacaCarreta = "";
    ?>
        <td><input type="text" id="carreta" name="NrPlacaCarreta" value="<?php echo $NrPlacaCarreta; ?>"/></td>
    <?php
       }
    ?>
    <script>
        var DsTpVeiculo = "<?php echo $DsTpVeiculo; ?>";
        if(DsTpVeiculo == "Cavalo Truck"){
            alert("Minha mensagem Cavalo Truck");
        }else if(DsTpVeiculo == "Bitruck" || DsTpVeiculo == "Truck"){
            alert("Minha mensagem Bitruck ou Truck");
        }
    </script>
    
14.07.2016 / 15:05