How to display a word in block a word according to certain parameters? [closed]

0

I need to display a name in a form field with buttons. If the user selects the number 1 in the previous field, in the following field in block mode (so that it is not modifiable by the user), it should show for example the word "career"; if you select the number 2 you should show for example "contractor" ...; When the user clicks the Submit button, you should save this information (the number "1", the word "career" and the others in the previously created database created in phpmyadmin).

I leave here the code made so far

    
asked by anonymous 02.01.2017 / 13:32

1 answer

0

From what I understand you want to validate using the block, see if it serves using jQuery itself. It is very simple and very easy to understand, however if you need some feedback from PHP warns you, it would only suit or check if Antonio's model is good.

jQuery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

HTML

<formid="formulario" method="" action="">
 <select id="opcao">
  <option value="">Selecione a opção</option>
  <option value="1">Opção 1</option>
  <option value="2">Opção 2</option>
 </select>
 <input type="text" id="retorno" disabled />
</form>

Script

$(document).ready(function(){
 $('#opcao').change(function(){
  var selecionado = $(this).val();
  if(selecionado == ""){
   $("#retorno").val("Opção não Selecionada");
  }else{
   if(selecionado == 1){
    $("#retorno").val("Contratro");
   }
   if(selecionado == 2){
    $("#retorno").val("Carreira");
   }
   if(selecionado == 3){
    $("#retorno").val("Outra Opção");
   }
  }
 });
});
    
02.01.2017 / 15:43