Necesito que cuando el usuario decida enviar un email mediante mi web, indique mediante un select a qué "departamento" quiere enviarlo (ej: administracion, finanzas, webmaster,etc).
Tengo un formulario con autentificación.
Código HTML:
<html> <head> <SCRIPT> function validateForm(_f) { var _b="Aquí están los datos que has ingresado:"; var _l="¿Quieres enviar estos datos?"; var _n="\n"; var _t="\t"; var _s=""; for(var _obj = _f.firstChild; _obj ; _obj=_obj.nextSibling) { if(_obj.name!=undefined) { /* * Pick up the title if it exists - otherwise use the name of the object. */ if(!_obj.header)_obj.header=_obj.name; /* * Deal with Text and Hidden and TextArea */ if(_obj.type=="text" || _obj.type=="hidden" || _obj.type=="textarea") _s+=_obj.header+_t+_obj.value+_n; /* * Deal with Radio Buttons, and Checkboxes */ if((_obj.type=="radio"||_obj.type=="checkbox")&&_obj.checked) { _s+=_obj.header+_t+_obj.value+_n; } /* * Deal with Select Boxes */ var _regExp=/select/i; if(_obj.type.match(_regExp)) _s+=_obj.header+_t+_obj.value+_n; } } return confirm(_b+_n+_n+_s+_n+_l); } </SCRIPT> <script> function LP_data(evt){ var key = evt.which || event.keyCode; // Código de tecla. if ((key < 48 || key > 57) && key != 8){ // Si no es número o retroceso if (evt.preventDefault) { evt.preventDefault(); } else { event.returnValue = false; } } } </script> </head> <body bgcolor="#FFFCD5" background="../informe_azul.PNG"> <FORM name=f1 onsubmit="return validateForm(document.f1)" method="post" action="contact.php"> <input type="text" name="Nombre:" size="2" value="JUANITO PEREZ" readonly="readonly"> <input type="text" name="Mes: " size="2" value="-- MES --" maxlength="15"> <input type="text" name="Libros:" size="2" onkeypress="LP_data(event)" value="0" maxlength="3"> </p> <input type="text" name="Folletos:" size="2" onkeypress="LP_data(event)" value="0" maxlength="3"> <select name="Departamento:" id="Departamento:" size="1"> <option selected>-- Departamento --</option> <option value="Webmaster" header="[email protected]">Webmasterr</option> <option value="Finanzas" header="[email protected]">Finanzas</option> <option value="Administración" header="[email protected]">Administración</option> </select></p> </p> <INPUT type=submit value="Enviar Informe"></p> </form> </body> </html>
Código PHP:
<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link
// get posted data into local variables
$EmailFrom = "[email protected]";
$EmailTo = Trim(stripslashes($_POST['Departamento:']));
$Subject = "Envio de Informe";
$Nombre = Trim(stripslashes($_POST['Nombre:']));
$Mes = Trim(stripslashes($_POST['Mes: ']));
$Libros = Trim(stripslashes($_POST['Libros:']));
$Folletos = Trim(stripslashes($_POST['Folletos:']));
// prepare email body text
$Body = "";
$Body .= "Nombre:";
$Body .= $Nombre;
$Body .= "\n";
$Body .= "Mes: ";
$Body .= $Mes;
$Body .= "\n";
$Body .= "Libros:";
$Body .= $Libros;
$Body .= "\n";
$Body .= "Folletos:";
$Body .= $Folletos;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Este el código especifico del HTML con el que tengo el problema:
Código HTML:
<select name="Departamento:" id="Departamento:" > <option selected>-- Departamento --</option> <option value="Webmaster" header="[email protected]">Webmasterr</option> <option value="Finanzas" header="[email protected]">Finanzas</option> <option value="Administración" header="[email protected]">Administración</option> </select></p>
Espero que me hallan entendido, y muchas gracias de antemano!!
![sonriente](http://static.forosdelweb.com/fdwtheme/images/smilies/smile.png)
DE AQUÍ SAQUÉ EL JAVASCRIPT PARA CONFIRMAR LOS DATOS INGRESADOS:
[URL="http://javascripts.astalaweb.com/Formularios%20III/Formulario/Confirma%20todos%20los%20datos.htm"][/URL]