When submitting form, how do I see the result referring to the options chosen?

Asked

Viewed 69 times

-1

Hey there, guys! My question is basically this. I have a form, where people put their name, phone, city, product option (property/ car). When clicking submit, I need a screen with a table of values referring to your product option.

For example, I filled in the data and placed it immobile. When submitting the form, the table of values will appear.

Note: The form code is ready and it is already sending the data to the barcode. However, I need to know how to make appear the product option that the customer chose, when filling it.

How can I do that?

      <h2>SIMULE AGORA SEU CONSÓRCIO!</h2><br/><br/>
  <div class="col-md-6">
         <img src="img/simule.jpg" class="imagem" alt="Vitor Cons�rcios">
  </div>
  <div class="col-md-1"></div>
  <form action="simulador.php" method="post" name="dados" id="dados" onSubmit="return validaform()">
        <div class="col-md-5 esquerda">
                       Selecione o bem<br/>
                       <select name="tipo" type="text" class="contat3" placeholder="Selecione o bem">
                       <option value="Im�vel"" 
                       style="background-color: #fff;">Imóveis</option>
                       <option value="Autom�vel"" 
                       style="background-color: #fff;">Automóveis</option>
                       <option value="Moto" style="background-color: #fff;">Motos</option>
                      </select><br/>
                     Selecione o plano<br/>
                     <select name="plano" type="text" class="contat3">
                       <option value="Crédito"" 
                     style="background-color: #fff;">Crédito</option>
                       <option value="Parcela"" 
                     style="background-color: #fff;">Parcela</option>
                     </select><br/>


                     <input name="valorcon" type="text" id="valorcon" class="contat3"  placeholder="Digite o valor" maxlength="1000" /><br/>



                     <input name="nomecon" type="text" id="nomecon" class="contat3"  placeholder="Nome"  maxlength="1000" /><br/>





                     <input name="telefone" type="text" 
                      onkeypress="Mascara('TEL',this,event);"
                     type="text" id="telefone" class="contat3"  placeholder="Telefone" />

                     <!--- 
                     <input name="tel2" type="text" id="tel2" onkeypress="Mascara('TEL',this,event);" /><br/>
                     --->



                     <input name="emailcon" type="text" id="emailcon" class="contat3"  placeholder="E-mail"  maxlength="1000" /><br/>



                     <input name="cidadecon" type="text" id="cidadecon" class="contat3"  placeholder="Cidade"  maxlength="1000" />


                     <br/><br/><br/>
                     <a id="enviar-form" class="button solid-color" href="#">Enviar</a>
                     <input type="submit" id="enviar-form-btn" style="display: none;" />

        </div>         
   </form>
  • In the.php simulator you will get the data, process the data and mount the screen you need.

  • Hi @Glenysmitchell, I didn’t get it very well.

  • all form data is sent to the simulator page.php. There you receive this data and based on what was typed mounts the screen.

  • @Glenysmitchell And how do I make so that when the visitor chooses the product option, appear the table referring to it?

  • Form with database: If you want to do it on one screen, you will have to use ajax, or jquery post/get to do it.

  • Form without database: The objects to be loaded must already exist on the screen, but hidden, and only when the user chooses this option, should appear the portion of the screen he wants to display. Which of the two?

  • @Glenysmitchell Can you provide me with an example code?

  • I’ll put together an answer, a moment.

  • All right, @Glenysmitchell. I’m on hold!

  • Your site has jquery?

Show 5 more comments

1 answer

0

If this table comes with information from a database, I suggest you do it with jquery and post/get, this link has two examples: https://www.w3schools.com/jquery/ajax_post.asp

If you don’t need this you will have a table hidden by the Hidden attribute:

<select name="tipo" type="text" class="contat3" placeholder="Selecione o bem" id="tipo">
    <option value="Imóvel" style="background-color: #fff;">Imóveis</option>
    <option value="Automóvel" style="background-color: #fff;">Automóveis</option>
    <option value="Moto" style="background-color: #fff;">Motos</option>
</select>
<div id="tabela_escondida" hidden>
    <table>
        <tr>
            <th>colunas</th>
        </tr>
        <tr>
            <td>valores</td>
        </tr>
    </table>
</div>

And a jquery or javascript to make the table appear when the option is chosen. Example with jquery:

$('#tipo').change(function(){ //ativa a função ao mudar o select
    var escolha = $("#tipo option:selected").val();
    alert('o usuario escolheu:' + escolha); //teste para ver o que o usuário escolheu
    if(escolha == 'A')
    {
        $('#tabela_escondida').show(); //mostra a div que tem a tabela dentro
    }
    else
    {
        $('#tabela_escondida').hide(); //esconde a div que tem a tabela dentro
    }
});

PS: can remove the entire Alert line, serves only for testing.

if it is to do in a second moment, within the simulator.php you will place a conditional.

if($_POST['tipo'] == 'Imóvel') hearder('location: paginaComAtabelaA.php');
else if($_POST['tipo'] == 'Automóvel') hearder('location: paginaComAtabelaB.php');
  • Hi Glenys, thank you very much! But this table in the case can only appear when the person clicks to send. In this case, what should I do?

  • In this case, I insist, you will have to do it on the screen of simulating.php, or a screen after that.

  • Well, I already have the pages/screens ready, with the table for each. However, I do not know how to make it direct to them according to the chosen good/product option.

  • Ahhhhhhhhh Iiim, I will edit reply.

  • Thanks! In case just put the last code right?

  • Yes, but first you have to see where this simulator page.php is sending the user.

  • It didn’t work out so well :/

  • Glenys, is there any way to contact you? It takes a lot to resolve this, if necessary until I pay you a fee!

  • Let’s try to figure it out here. How many lines are on your simulator page.php?

  • On the page has 424 lines.

  • Pass me your email or Whats.

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.