Foros del Web » Creando para Internet » HTML »

Validar seleccion

Estas en el tema de Validar seleccion en el foro de HTML en Foros del Web. Hola tengo dos problemas con este codigo. 1- Tengo una uncion llamada valida_obra que valida el primer campo de seleccion que se llama league, para ...
  #1 (permalink)  
Antiguo 18/11/2009, 18:40
 
Fecha de Ingreso: febrero-2008
Mensajes: 26
Antigüedad: 16 años, 2 meses
Puntos: 0
Validar seleccion

Hola tengo dos problemas con este codigo.


1- Tengo una uncion llamada valida_obra que valida el primer campo de seleccion que se llama league, para que cuando alguien no seleccione una de las opciones, envie un mensaje de alerta pidiendo una de las opciones

2- necesito enviar una copia del correo que se envia al correo ingresado por el usuario en el campo email, pero al enviar el email no se recibe la copia, solo el original ke va al correo principal
creo que me explique bien aki les dejo el codigo del formulario y a continuacion el codigo del enviar-php
Código:
<html>


<head>
 



<title>Solicitud de Material</title>

<script type="text/javascript">


var Hospital_Perez_Carreno = new Array("Victor Ojeda")
var Maternidad_Santa_Ana = new Array("Benjamin Doctors")
var Hospital_Domingo_Luciani = new Array("Gilmer Henriquez")
var Hospital_Algodonal = new Array("Victor Ojeda")
var Hospital_JM_de_los_Rios = new Array("Samuel Doctors")
var Hospital_Luis_Ortega_Porlamar = new Array("Xavier Quintana")
var Hospital_Central_Maracay = new Array("Lucybel Henriques")
var Hospital_San_Carlos = new Array("Sixto Coronil")
var Hospital_Los_Roques = new Array("Jose Farias")
var almacen = new Array("Almacen")
function loadList(which) {
  var theList = eval(which);
  document.theForm.team.options.length = theList.length;
  for (i=0; i<theList.length; i++) {
    document.theForm.team.options[i] = new Option(theList[i], theList[i]);
  }
}
function resetLists() {
  loadList("");
  document.theForm.league.options[0].selected = true;
}
window.onload = resetLists;


</script>

<script>
function valida_envia(){ 
   	//valido el nombre 
   	if (document.theForm.email.value.length==0){ 
      	 alert("Ingrese su Correo Electronico") 
      	 document.theForm.email.focus() 
      	 return 0; 
   	} 
	
	//el formulario se envia
	alert("Muchas gracias por enviar el formulario");
	document.theform.submit();
}
	
	
 </script>
 
 <script>
function valida_obra(){ 
   	//valido el nombre 
   	if (document.theForm.league.value.length==''){ 
      	 alert("Seleccione una opcion") 
      	 document.theForm.league.focus() 
      	 return 0; 
   	} 
	
	//el formulario se envia
	alert("Muchas gracias por enviar el formulario");
	document.theform.submit();
}
	
	
 </script>
 
 
</head>

<body>

<table width="600" border="1">
  <tr>
    <td><div align="center"><strong>Requisicion de Materiales</strong></div></td>
  </tr>
</table>
<table width="600" border="1">

  <tr>
    <td width="260"><strong>Fecha de Pedido</strong> (<em>La entrega sera efectuada 7 dias despues de la solicitud</em>) </td>
   
    <td width="224"><script languaje="JavaScript">





var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado")
var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")
document.write("<strong><small><font color='000000' face='Arial'>"+dayarray[day]+" "+daym+" de "+montharray[month]+" de "+year+"</font></small></strong>")


</script> 

</td>
  </tr>
</table>
<table width="600" border="1">
  <tr>
    <td><form name="theForm"  method="post" action="ipse.com.ve/enviar.php">
   
Obra Solicitante:     
      <select name="league" onChange="loadList(this.options[this.selectedIndex].value)" size="1">
<option value="">Seleccione una Opcion</option>
<option value="Hospital_Perez_Carreno">Hospital Perez Carreno</option>
<option value="Maternidad_Santa_Ana">Maternidad Santa Ana</option>
<option value="Hospital_Domingo_Luciani">Hospital Domingo Luciani</option>
<option value="Hospital_Algodonal">Hospital Algodonal</option>
<option value="Hospital_JM_de_los_Rios">Hospital JM de los Rios</option>
<option value="Hospital_Luis_Ortega_Porlamar">Hospital Luis Ortega Porlamar</option>
<option value="Hospital_Central_Maracay">Hospital Central de Maracay</option>
<option value="Hospital_San_Carlos">Hospital de San Carlos</option>
<option value="Hospital_Los_Roques">Hospital Los Roques</option>
<option value="almacen">Almacen</option>
</select>
Encargado:
<select name="team" size="1"></select>

</table>

<table width="600" border="1">
  <tr>
    <td width="330"><div align="center"><strong>Ingrese su correo electronico</strong><span class="required">*</span></div></td>
     <td width="270"><input type="text" size="40" name="email" class="text" value=""  onblur="validate(this,'Required')"   maxlength="40" maxsize="40" />  </td>
  </tr>
</table>


<table width="600" border="1">
  <tr>
    <td width="398"><div align="center"><strong>Descripcion del Material</strong></div></td>
    <td width="89"><div align="center"><strong>Cantidad</strong></div></td>
    <td width="91"><div align="center"><strong>Unidad</strong></div></td>
  </tr>
</table>
<table width="600" border="1">
  <tr>
    <td width="401"><input type="text" size="60" name="pedido1" class="text" value=""    maxlength="60" maxsize="60" />  </td>
    
    <td width="88"><input type="text" size="9" name="cant1" class="text" value=""    maxlength="9" maxsize="9" /></td>
    <td width="89"><input type="text" size="9" name="unidad1" class="text" value=""  maxlength="9" maxsize="9" id="unidad1" />  </td>
  </tr>
  <tr>
    <td width="401"><input type="text" size="60" name="pedido2" class="text" value=""    maxlength="60" maxsize="60" />  </td>
     <td width="88"><input type="text" size="9" name="cant2" class="text" value=""    maxlength="9" maxsize="9" />  </td>
    <td width="89"><input type="text" size="9" name="unidad2" class="text" value=""  maxlength="9" maxsize="9" id="unidad1" />  </td>
  </tr>
  <tr>
  <td width="401"><input type="text" size="60" name="pedido3" class="text" value=""    maxlength="60" maxsize="60" /></td>
    <td width="88"><input type="text" size="9" name="cant3" class="text" value=""    maxlength="9" maxsize="9" />  </td>
    <td width="89"><input type="text" size="9" name="unidad3" class="text" value=""  maxlength="9" maxsize="9" id="unidad1" />  </td>
  </tr>
  <tr>
    <td width="401"><input type="text" size="60" name="pedido4" class="text" value=""    maxlength="60" maxsize="60" />  </td>
      <td width="88"><input type="text" size="9" name="cant4" class="text" value=""    maxlength="9" maxsize="9" />  </td>
    <td width="89"><input type="text" size="9" name="unidad4" class="text" value=""  maxlength="9" maxsize="9" id="unidad1" />  </td>
  </tr>
  
</table>

<table width="578" border="1">
  <tr>
    <td><strong>Observaciones</strong></td>
    <td> 
    <td width="401">        <textarea name="ob" cols="57" rows="4"></textarea>
        
   
    </td></td>
  </tr>
</table>

<input type="submit" class="btn" value="Enviar"  onclick="valida_envia()"  onclick="valida_obra"/>




</body>
</html>

Gracias

Última edición por el_titan; 18/11/2009 a las 18:55
  #2 (permalink)  
Antiguo 18/11/2009, 18:56
 
Fecha de Ingreso: febrero-2008
Mensajes: 26
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Validar seleccion

Código:
<?
	$sendTo = "[email protected]" . " . ", $email";
	$subject = "IPSE";
	$headers="From: IPSE" . "\r\n";
	$headers.="Content-type:text/html; charset=\"utf-8\"\r\n";
	$headers.='X-Mailer: PHP/'. phpversion();

	$count = 0;
	$COUNT_FILE = "count_data.txt";
	
if (file_exists($COUNT_FILE)) {

	$fp = fopen("$COUNT_FILE", "r+");
	flock($fp, 1);
	$count = fgets($fp, 4096);
	$count += 1; 
	fseek($fp,0);
	fputs($fp, $count);
	flock($fp, 3);
	fclose($fp);
	
} else {

	echo "Can't find file, check '\$file' var...<BR>";
}
	$message = "<b>Solicitud Numero </b>:". $count . "<br> \n";

	
	$message .= "<b>Obra Solicitante </b>: ". $_POST['league'] . "\n";
	$message .= "<b>Encargado </b>:" . $_POST['team'] . "<br> \n" ;
	
	$message .= "". $_POST['pedido1'] . "\n";
	$message .= "" . $_POST['cant1'] . "\n";
	$message .= "" . $_POST['unidad1'] . "<br> \n";
	
 	$message .= "". $_POST['pedido2'] . "\n";
	$message .= "" . $_POST['cant2'] . "\n";
	$message .= "" . $_POST['unidad2'] . "<br>\n";
	
	$message .= "". $_POST['pedido3'] . "\n";
	$message .= "" . $_POST['cant3'] . "\n";
	$message .= "" . $_POST['unidad3'] . "<br>\n";
	
	$message .= "". $_POST['pedido4'] . "\n";
	$message .= "" . $_POST['cant4'] . "\n";
	$message .= "" . $_POST['unidad4'] . "<br>\n";
	
	$message .= "". $_POST['pedido5'] . "\n";
	$message .= "" . $_POST['cant5'] . "\n";
	$message .= "" . $_POST['unidad5'] . "<br>\n";
	
	
	$message .= "<b>Observaciones</b>: " . $_POST['ob'] . "\n";

	

	
	

	mail($sendTo, $subject, $message, $headers, $count);


	echo "Mensaje enviado";
	

?>
  #3 (permalink)  
Antiguo 21/11/2009, 16:39
 
Fecha de Ingreso: febrero-2008
Mensajes: 26
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Validar seleccion

alguna ayudita??
  #4 (permalink)  
Antiguo 23/11/2009, 10:51
 
Fecha de Ingreso: febrero-2008
Mensajes: 26
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Validar seleccion

nada? por favor?
  #5 (permalink)  
Antiguo 23/11/2009, 12:34
Avatar de caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años
Puntos: 1284
Respuesta: Validar seleccion

Hola:

No te responden porque el tema no está en el foro adecuado... y al estar poco reducido es más difícil ver el problema... Por lo que veo la variable SendTo puede estar mal:

$sendTo = "[email protected]" . " . ", $email";

Parece que hay un punto y luego una coma, y creo que no es correcto... también puedes usar 2 instrucciones mail... y otra cosa, comprueba que tu servidor acepta la variable $email... tal vez debiera ser $_POST["email"]... si van por ahí los tiros, te recomiendo que reportes el mensaje para que lo muevan a php

Saludos
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo
  #6 (permalink)  
Antiguo 23/11/2009, 21:27
 
Fecha de Ingreso: febrero-2008
Mensajes: 26
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Validar seleccion

ya posteo el tema en php, para ver como puedo solucionarlo

gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:06.