Re: problemas con un formulario y campos obligatorios

From: Date: Wed, 18 Dec 2013 13:55:41 +0000
Subject: Re: problemas con un formulario y campos obligatorios
References: 1 2  Groups: php.general.es 
Request: Send a blank email to general-es+get-65607@lists.php.net to get a copy of this message
En el JS buscas los elementos del DOM por id con jQuery haciendo: $("add_sub_prod") Lo correcto sería: $("#add_sub_prod") Un saludo. 2013/12/18 Diego Hidalgo <dhidalgo@chma.edu.pe> > Hola! Has hecho debug con el firebug o con el chrome? Apreta f12 y luego > dale click al boton + a ver si sale algun error para q leas su descripcion > y le hagas seguimiento. > > Saludos, > > Diego Hidalgo Garrido > Asociación Cultural Christa McAuliffe > Cel. 957602603 RPM #957602603 > dhidalgo@chma.edu.pe > www.chma.edu.pe > El 18/12/2013 08:37, "Irantzu Leunda Biskarret" <irantzu@dosalcubo.net> > escribió: > > > Hola atodos estoy haciendo un formulario de inscripcion en php y mysql y > > ademas tengo un par de comportamietos de javascript y necesito si alguien > > puede ayudarme. > > > > Al poner los campos obligatorios me deja de funcionar el boton “+” > > > > La url es esta: > > > > > > http://www.cdzornotza.com/zornotza_cross/inscripcionew_alevin.php > > > > En este otro formulario que aun no he puesto lo de los campos > obligatorios > > me funciona bien > > > > > > http://www.cdzornotza.com/zornotza_cross/inscripcionew_popular.php > > > > Necesito que ambos formularios lleven los dos comportamientos y la verdad > > es que no encuentro la razón, serían tan amables, como siempre de > colaborar > > conmigo? > > > > > > Muchas gracias > > > > Pongo aqui en código de la que no me funciona: > > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " > > > > http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > <html > > xmlns="http://www.w3.org/1999/xhtml"> > > <head> > > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > > /> > > <title>Zornotza Cross Internacional</title> > > <link href="estilos_cross.css" rel="stylesheet" > > type="text/css" /> > > <style type="text/css"></style> > > <script type="text/javascript" > > src="../ckeditor/ckeditor.js"></script> > > <script language="JavaScript" type="text/JavaScript" > > src="../js2/mootools-release-1.11.js"></script> > > <script language="JavaScript" type="text/JavaScript" > > src="../js2/w2s-mootools.js"></script> > > <script language="JavaScript" src="js/jquery-1.4.4.min.js" > > type="text/javascript"></script> > > <script language="JavaScript" src="js/jquery.validate.js" > > type="text/javascript"></script> > > > > <!--validar campos obligatorios--> > > <script type="text/javascript"><!-- > > $().ready(function() { > > $("#formu").validate(); > > }); > > // --></script> > > <!-- comportamiento del boton + --> > > <script type="text/javascript"> > > var contLin = 3; > > function agregar() { > > var tr, td, tabla; > > > > tabla = document.getElementById('tabla'); > > tr = tabla.insertRow(tabla.rows.length); > > td = tr.insertCell(tr.cells.length); > > td.innerHTML = "<select id='sel" + contLin + "'>" > > + > > "<option>1" + > > "<option>2" + > > "<option>3"; > > td = tr.insertCell(tr.cells.length); > > td.innerHTML = "<input type='text' id='t" + contLin + > > "1' value='t" + > > contLin + "1'>"; > > td = tr.insertCell(tr.cells.length); > > td.innerHTML = "<input type='text' id='t" + contLin + > > "2' value='t" + > > contLin + "2'>"; > > contLin++; > > } > > function borrarUltima() { > > ultima = document.all.tabla.rows.length - 1; > > if(ultima > -1){ > > document.all.tabla.deleteRow(ultima); > > contLin--; > > } > > } > > </script> > > <!-- fin --> > > > > <script language="JavaScript" type="text/JavaScript"> > > <!-- > > function MM_jumpMenu(targ,selObj,restore){ //v3.0 > > > > eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); > > if (restore) selObj.selectedIndex=0; > > } > > > > window.onerror=function(){ > > > > return false; > > } > > > > window.addEvent("load",function(){ > > var ctr = 1; > > > > $("add_sub_prod").addEvent("click",function(event){ > > > > $("ref_add_sub_prod")._insert({"before":"<tr><td><input > > type='text' name='categoria["+ctr+"]' > > id='categoria["+ctr+"]' > > size='15'></td><td><input type='text' > > name='sexo["+ctr+"]' > > id='sexo["+ctr+"]' > > size='15'></td><td><input type='text' > > name='licencia["+ctr+"]' id='licencia["+ctr+"]' > > size='8'></td><td><input > > type='text' name='nombre["+ctr+"]' > > id='nombre["+ctr+"]'></td><td><input > > type='text' name='apellidos["+ctr+"]' > > id='apellidos["+ctr+"]'></td><td><input > > type='text' name='club["+ctr+"]' > > id='club["+ctr+"]'></td><td > > width='50'><input type='text' > > name='nacimiento["+ctr+"]' > > id='nacimiento["+ctr+"]' size='8'></td></tr>" > > > > }); > > > > ctr++; > > }); > > }); > > > > //--> > > </script> > > > > > > </head> > > > > <body> > > <div class="pre_cross"> > > <div id="contenedor_insc"> > > <? include('cabecera.php'); ?> > > <div id="contenido"> > > <? //include('izquierda.php'); ?> > > <div id="derecha2"> > > <h1 class="titulo_n"> Formulario de inscripción.</h1> > > <h1 class="titulo2_n">Para realizar su inscripción debe rellenar > > el formulario siguiente.<br /><span style="color: red;">(*) Todos > > los > > campos son obligatorios.</span></h1> > > > > <!--<div id="formulario">--> > > <form id="formu" name="f" method="post" > > action="insertar_alevin_ok.php" enctype="multipart/form-data"> > > <!--<form name='f' method='post' > > action='insertar_alevin_ok.php' > > enctype='application_x-www-form-urlencoded'>--> > > <table class="tabla1" width="800" align="center"> > > <tr> > > <th colspan="6">DATOS DEL CLUB</th> > > </tr> > > <tr> > > <td> <span style="color: red;">*</span>Entidad: > > </td> > > <td colspan="2"> > > <input id="entidad" class="required" type="text" > > name="entidad" > > maxlength="45" /> > > <!--<input type='text' name='entidad' > > class='caja' size="45">--> > > </td> > > > > <td> <span style="color: red;">*</span>Delegado: > > </td> > > <td colspan="2"><input type='text' > > name='delegado' > > class='required' size="45"></td> > > </tr> > > <tr> > > <td> <span style="color: red;">*</span>Dirección: > > </td> > > <td colspan="6"><input type='text' > > name='direccion' > > class='required' size="97"></td> > > </tr> > > <tr> > > <td> <span style="color: red;">*</span>Población: > > </td> > > <td><input type='text' name='poblacion' > > class='required'></td> > > <td> <span style="color: red;">*</span>Cod. Postal: > > </td> > > <td><input type='text' name='cp' > > class='required'></td> > > <td> <span style="color: > > red;">*</span>E.mail:</td> > > <td><input type='text' name='email' > > class='required'></td> > > </tr> > > <tr> > > <td> <span style="color: red;">*</span>Provincia: > > </td> > > <td><input type='text' name='provincia' > > class='required'></td> > > <td> <span style="color: red;">*</span>Tfno: > > </td> > > <td><input type='text' name='telefono' > > class='required'></td> > > <td> <span style="color: red;">*</span>Fax: > > </td> > > <td><input type='text' name='fax' > > class='required'></td> > > </tr> > > </table> > > <table class="tabla3" width="900" align="center"> > > <tr> > > <th colspan="7">DATOS DE ATLETAS</th> > > </tr> > > <tr> > > <th>CATEGORIA <span style="color: red;">*</span> > > <br />(Alevin o > > Infantil)</th> > > <th>SEXO <span style="color: red;">*</span> <br > > />(Masculino o > > Femenino)</th> > > <th>LICENCIA <span style="color: > > red;">*</span></th> > > <th>NOMBRE <span style="color: > > red;">*</span></th> > > <th>APELLIDOS <span style="color: > > red;">*</span></th> > > <th>CLUB/<br/>CTRO ESCOLAR <span style="color: > red;">*</span></th> > > <th>AÑO NAC. <span style="color: > > red;">*</span></th> > > > > </tr> > > <tr id='ref_add_sub_prod'> > > <td><input type='text' name='categoria[0]' > > id='categoria[0]' > > size="15" class='required'></td> > > <td><input type='text' name='sexo[0]' > > id='sexo[0]' size="15" > > class='required'></td> > > <td><input type='text' name='licencia[0]' > > id='licencia[0]' > > size="8" class='required'></td> > > <td><input type='text' name='nombre[0]' > > id='nombre[0]' > > class='required'></td> > > <td><input type='text' name='apellidos[0]' > > id='apellidos[0]' > > class='required'></td> > > <td><input type='text' name='club[0]' > > id='club[0]' > > class='required'></td> > > <td><input type='text' name='nacimiento[0]' > > id='nacimiento[0]' > > size="8" class='required'></td> > > > > <td class='txt'><input type='button' > > id='add_sub_prod' > > name='add_sub_prod' value='+' class='button_min' > > /></td> > > > > </tr> > > <tr> > > <td class='center' height='40' colspan='7'> > > <input type="submit" name="enviar" id="enviar" > > class='button' > > value="INSERTAR"> > > <!--<input type='submit' class='button' > > value='INSERTAR' />--> > > </td> > > </tr> > > </table> > > </form> > > </div> > > </div><!-- fin contenido--> > > <? include('pie.php'); ?> <!-- fin pie--> > > > > </div> > > </div> > > </body> > > </html> >

« previous php.general.es (#65607) next »