Ver Mensaje Individual
  #5 (permalink)  
Antiguo 20/09/2011, 07:35
miriamgomez
 
Fecha de Ingreso: abril-2008
Mensajes: 348
Antigüedad: 16 años, 1 mes
Puntos: 1
Respuesta: Armar formulario "muy completo"

Hola:

Voy poniendo los trozos:

Con esto genero el combo:

Código Javascript:
Ver original
  1. function cambiar()
  2. {
  3. var index=document.forms.formulario.servicios.selectedIndex;
  4.  
  5. formulario.meses.length=0;
  6.  
  7. if(index==2) Arte();
  8. if(index==3) Ciencia();
  9. if(index==4) Compra();
  10. if(index==5) Deportes();
  11. if(index==10) Negocios();
  12. if(index==6) Educacion();
  13. if(index==7) Hogar();
  14. if(index==12) Sociedad();
  15. if(index==8) Internet();
  16. if(index==9) Juegos();
  17. if(index==11) Salud();
  18. if(index==13) Turismo();
  19. if(index==1) Adultos();
  20.  
  21. }
  22. function Arte(){
  23. opcion0=new Option("...","...","defauldSelected");
  24. opcion1=new Option("Literatura","Literatura");
  25. opcion2=new Option("Cine","Cine");
  26. opcion3=new Option("Fotografía","Fotofrafía");
  27.  
  28. document.forms.formulario.meses.options[0]=opcion0;
  29. document.forms.formulario.meses.options[1]=opcion1;
  30. document.forms.formulario.meses.options[2]=opcion2;
  31. document.forms.formulario.meses.options[3]=opcion3;
  32. }
  33. function Ciencia(){
  34. opcion0=new Option("...","...","defauldSelected");
  35. opcion1=new Option("Ingeniería","Ingeniería");
  36. opcion2=new Option("Media Ambiente","Medio Ambiente");
  37. opcion3=new Option("Arquitectura","Arquitectura");
  38.  
  39.  
  40. document.forms.formulario.meses.options[0]=opcion0;
  41. document.forms.formulario.meses.options[1]=opcion1;
  42. document.forms.formulario.meses.options[2]=opcion2;
  43. document.forms.formulario.meses.options[3]=opcion3;
  44.  
  45. }
  46.  
  47. function Compra(){
  48. opcion0=new Option("...","...","defauldSelected");
  49. opcion1=new Option("Casa y Jardín","Casa y Jardín");
  50. opcion2=new Option("Animales","Animales");
  51. opcion3=new Option("Automoviles","Automoviles");
  52.  
  53.  
  54.  
  55. document.forms.formulario.meses.options[0]=opcion0;
  56. document.forms.formulario.meses.options[1]=opcion1;
  57. document.forms.formulario.meses.options[2]=opcion2;
  58. document.forms.formulario.meses.options[3]=opcion3;
  59.  
  60. }
  61.  
  62. function Deportes(){
  63. opcion0=new Option("...","...","defauldSelected");
  64. opcion1=new Option("Automovilismo","Automovilismo");
  65. opcion2=new Option("Futbol","Futbol");
  66. opcion3=new Option("Tenis","Tenis");
  67. opcion4=new Option("Padel","Padel");
  68.  
  69.  
  70. document.forms.formulario.meses.options[0]=opcion0;
  71. document.forms.formulario.meses.options[1]=opcion1;
  72. document.forms.formulario.meses.options[2]=opcion2;
  73. document.forms.formulario.meses.options[3]=opcion3;
  74. document.forms.formulario.meses.options[4]=opcion4;
  75.  
  76. }
  77. function Negocios(){
  78. opcion0=new Option("...","...","defauldSelected");
  79. opcion1=new Option("Bares y Restaurantes","Bares y Restaurantes");
  80. opcion2=new Option("Fiestas","Fiestas");
  81. opcion3=new Option("Asesorias","Asesorias");
  82. opcion4=new Option("Limpiezas","Limpiezas");
  83.  
  84.  
  85. document.forms.formulario.meses.options[0]=opcion0;
  86. document.forms.formulario.meses.options[1]=opcion1;
  87. document.forms.formulario.meses.options[2]=opcion2;
  88. document.forms.formulario.meses.options[3]=opcion3;
  89. document.forms.formulario.meses.options[4]=opcion4;
  90.  
  91. }
  92. function Educacion(){
  93. opcion0=new Option("...","...","defauldSelected");
  94. opcion1=new Option("Cursos a distancia","Curso a distancia");
  95. opcion2=new Option("Idiomas","Idiomas");
  96. opcion3=new Option("Colegios","Colegios");
  97. opcion4=new Option("Web educativas","Web educativas");
  98.  
  99.  
  100. document.forms.formulario.meses.options[0]=opcion0;
  101. document.forms.formulario.meses.options[1]=opcion1;
  102. document.forms.formulario.meses.options[2]=opcion2;
  103. document.forms.formulario.meses.options[3]=opcion3;
  104. document.forms.formulario.meses.options[4]=opcion4;
  105.  
  106. }
  107. function Hogar(){
  108. opcion0=new Option("...","...","defauldSelected");
  109. opcion1=new Option("Cocina","Cocina");
  110. opcion2=new Option("Muebles","Muebles");
  111. opcion3=new Option("Decoración","Decoración");
  112. opcion4=new Option("Electrodomésticos","Electrodomésticos");
  113.  
  114.  
  115. document.forms.formulario.meses.options[0]=opcion0;
  116. document.forms.formulario.meses.options[1]=opcion1;
  117. document.forms.formulario.meses.options[2]=opcion2;
  118. document.forms.formulario.meses.options[3]=opcion3;
  119. document.forms.formulario.meses.options[4]=opcion4;
  120.  
  121. }
  122. function Sociedad(){
  123. opcion0=new Option("...","...","defauldSelected");
  124. opcion1=new Option("Política","Política");
  125. opcion2=new Option("Religion","Religion");
  126. opcion3=new Option("Historia","Historia");
  127. opcion4=new Option("Solidaridad","Solidaridad");
  128.  
  129.  
  130. document.forms.formulario.meses.options[0]=opcion0;
  131. document.forms.formulario.meses.options[1]=opcion1;
  132. document.forms.formulario.meses.options[2]=opcion2;
  133. document.forms.formulario.meses.options[3]=opcion3;
  134. document.forms.formulario.meses.options[4]=opcion4;
  135.  
  136. }
  137. function Internet(){
  138. opcion0=new Option("...","...","defauldSelected");
  139. opcion1=new Option("Informática","Informática");
  140. opcion2=new Option("Alojamiento","Alojamiento");
  141. opcion3=new Option("Chat","Chat");
  142. opcion4=new Option("Descargas","Descargas");
  143.  
  144.  
  145. document.forms.formulario.meses.options[0]=opcion0;
  146. document.forms.formulario.meses.options[1]=opcion1;
  147. document.forms.formulario.meses.options[2]=opcion2;
  148. document.forms.formulario.meses.options[3]=opcion3;
  149. document.forms.formulario.meses.options[4]=opcion4;
  150.  
  151. }
  152. function Juegos(){
  153. opcion0=new Option("...","...","defauldSelected");
  154. opcion1=new Option("Loterias-Quinielas","loterias-Quinielas");
  155. opcion2=new Option("Videojuegos","Videojuegos");
  156.  
  157.  
  158.  
  159.  
  160. document.forms.formulario.meses.options[0]=opcion0;
  161. document.forms.formulario.meses.options[1]=opcion1;
  162. document.forms.formulario.meses.options[2]=opcion2;
  163.  
  164.  
  165. }
  166. function Salud(){
  167. opcion0=new Option("...","...","defauldSelected");
  168. opcion1=new Option("Medicamentos","Medicamentos");
  169. opcion2=new Option("Medicina Alternativa","Medicina Alternativa");
  170. opcion3=new Option("Dietética","Dietética");
  171. document.forms.formulario.meses.options[0]=opcion0;
  172. document.forms.formulario.meses.options[1]=opcion1;
  173. document.forms.formulario.meses.options[2]=opcion2;
  174. document.forms.formulario.meses.options[3]=opcion3;
  175. }
  176. function Turismo(){
  177. opcion0=new Option("...","...","defauldSelected");
  178. opcion1=new Option("Agencias de Viajes","Agencias de Viajes");
  179. opcion2=new Option("Guias","Guias");
  180. opcion3=new Option("Casas Rurales","Casa Rurales");
  181.  
  182.  
  183.  
  184. document.forms.formulario.meses.options[0]=opcion0;
  185. document.forms.formulario.meses.options[1]=opcion1;
  186. document.forms.formulario.meses.options[2]=opcion2;
  187. document.forms.formulario.meses.options[3]=opcion3;
  188. }
  189. function Adultos(){
  190. opcion0=new Option("...","...","defauldSelected");
  191. opcion1=new Option("Contactos","Contactos");
  192. opcion2=new Option("Videos X","Videos X");
  193. opcion3=new Option("Tendencias","Tendencias");
  194.  
  195. document.forms.formulario.meses.options[0]=opcion0;
  196. document.forms.formulario.meses.options[1]=opcion1;
  197. document.forms.formulario.meses.options[2]=opcion2;
  198. document.forms.formulario.meses.options[3]=opcion3;
  199. }
  200. </script>

Usando esto cundo defino el form compruebo los campos:

onsubmit="MM_validateForm('nombre','','R','email', '','R','telefono','','R','servicios','','R','CAPTC HA_CODE','','R');return document.MM_returnValue">

Con esto cuento os numeros de carracteres para que esten en un rango, adema hay un trozo que compreuba que esta relleno unos campos

<script>
var timer=setInterval("COUNT_CHARACTERS();",10),Debugg er,Proceded;function COUNT_CHARACTERS(){var b=document.getElementById("descrpcion");document.g etElementById("Count").innerHTML="Comentarios: ("+b.value.length+" / 99)";if(b.value.length>99)b.value=b.value.substrin g(0,99)}
function VALIDATE_FIELDS(){Debugger="Se han encontrado los siguientes errores: \n \n";Proceded=!0;for(var b=["descripcion","Url","email"],a=0;a<b.length;a++){var c=document.getElementById(b[a]);if(b[a]=="email")c.value.indexOf("@")==-1&&(Debugger+="* El email proporcionado es incorrecto. \n",Proceded=!1);else if(b[a]=="descripcion"){if(c.value.length<10||c.value.len gth>99)Debugger=Debugger+"* El campo "+b[a]+" debe contener al menos 10 caracteres y menos de 99. \n",Proceded=!1}else c.value==
""&&(Debugger=Debugger+"* El campo "+b[a]+" no puede estar vacio. \n",Proceded=!1)}Proceded?document.forms.MyData.su bmit():alert(Debugger)}

El captchap, lo genero con un archico externo y lo tengo medio controlado

No se si sirvio de ayuda o lo lie mas

Se trata de unificar todos estos "trozos"

gracias por tus repsuetas