Change email destination by clicking a select option on a form

Asked

Viewed 78 times

1

Well, I have a form and need when selecting a select option to change:

1 line - action
2 line - value
3 line - value
15 line - Change where this is written environmentOrca2 to for example environmentOrca1

<form id="formulario2" name="formulario2" method="post" enctype="multipart/form-data" action="mail-lista-de-descontos.php"  >
        <input type="hidden" name="acao" id="acao" value="enviaOrca2" />
        <input type="hidden" name="mailTo" id="mailTo" value="[email protected]" />
        <label>Email:</label>
        <input type="email" name="email" id="email" data-required="1" data-title="E-mail" required>
        <label>Dia:</label>
        <select name="lista">
            <option value="Sexta15abril">Sexta 15 de Abril</option>
            <option value="Sábado16abril">Sábado 16 de Abril</option>
            <option value="Sexta22abril">Sexta 22 de Abril</option>
            <option value="Sábado23abril">Sábado 23 de Abril</option>
        </select>
        <label>Nomes Completos:</label>
        <textarea name="mensagem" id="mensagem" data-required="1" data-title="Mensagem" placeholder="Exemplo: João da silva, Tenório Antonio" ></textarea>
        <a href="javascript:enviaOrca2()" title="Enviar">Enviar</a>
    </form>

The only solution I found was this below only I do not know how it does to change several options at the same time

<select id='seuSelect' onChange='alteraAction(this.value)' >

// seus options aqui, lembre-se, cada option deve ter um 'value'

</select>

function alteraAction(valor) { 
if (valor == "Segunda Opção") {
    $('#idFormulario').attr('action', 'novaaction.php');
   }
}
  • Take a look @user4451 http://loudev.com/

  • You want a pickList? take a look at my answer and see if it helps you: http://answall.com/questions/114804/como-cria-um-formul%C3%A1rio-de-associa%C3%A7%C3%A3o-picklist-em-modal/114832#114832

  • Wellington Silva Ribeiro I joined this site but there the codes insert and remove from a container what I want is to change the text of some properties as action when I select an option in select, why each option of select goes to a different email

  • Gabriel Rodrigues As I said to Willington I just want the text of certain form properties to change as I make a choice in select

1 answer

0

Just add the change you want in Function

function alteraAction(valor) { 
if (valor == "Segunda Opção") {
    $('#idFormulario').attr('action', 'novaaction.php');
    $('#email').val('[email protected]');
   }
}
  • Nelson Teixeira is but there are 3 options so I put an IF?

  • elseif, switch, for... as you wish

Browser other questions tagged

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