Foros del Web » Programando para Internet » Javascript »

Validar Submit en javascript und C

Estas en el tema de Validar Submit en javascript und C en el foro de Javascript en Foros del Web. Hola espero me puedan ayudar. Estoy prgramando microcontrolador que tienen un servidor Web. la programacion es en C. estoy tratando de hacer un formulario dinamico. ...
  #1 (permalink)  
Antiguo 01/12/2010, 12:45
 
Fecha de Ingreso: diciembre-2010
Mensajes: 1
Antigüedad: 13 años, 4 meses
Puntos: 0
Exclamación Validar Submit en javascript und C

Hola
espero me puedan ayudar. Estoy prgramando microcontrolador que tienen un servidor Web. la programacion es en C. estoy tratando de hacer un formulario dinamico. Un formulario genere el otro. el problema que tengo es al oprimir el boton submit me genera el otro formulario sin importar la valiacion de los campos. No como hacer para que esto no suceda. ya que en C estoy activando el otro formulario. Existe algun script en el cual pueda activar el "for" dependiendo de alguna variable dentro del mismo formmulario? algo asi como un "if"
. Adjunto codigo...espero relamente me puedan ayudar o enviar un codigo o script.


Saludos,


Código PHP:
void cgiPV_editPV(charbufferphotovoltaik_tpv) {
   
int i 0;

   
strcat (buffer," <head>"
                  "<script type=\"text/javascript\">"
                  " function validarn(e) { "
// 1
                       
" tecla = (document.all) ? e.keyCode : e.which; "// 2
                  
" if (tecla==8) return true;" // 3
                  
" patron = /[1234567890.]/;" // 4
                  
" te = String.fromCharCode(tecla);" // 5
                  
" return patron.test(te);" // 6
                   
"} "
                  "function validar(){"
                  "if(formulario.namepv.value == \"\"){"
                  "alert('Insert Name de PV');"
                  "}"
                  "if(formulario.maxPIpv.value == \"\"){"
                  "alert('Insert Maximal PI');"
                  "}"
                  "document.formulario.submit();"
                  "}" 
);
  
strcat (buffer"  </script> " );
   
strcat(buffer"        <form name=formulario>\r\n");
   
strcat(buffer"      <table class=\"photovoltaik\">\r\n");// que se vea mas gordo
   
strcat(buffer"        <tr>\r\n");
   
strcat(buffer"        <th colspan=\"2\">PHOTOVOLTAIK\r\n");/// escribe
   
strcat(buffer"        </th>\r\n");
   
strcat(buffer"       </tr>\r\n");
    
strcat(buffer"       <tr>\r\n");
   
strcat(buffer"        <td>&nbsp;</td>\r\n");
   
strcat(buffer"        <td>\r\n");
   
strcat(buffer"        <form method=\"get\">\r\n");
   
strcat(buffer"        <input type=\"hidden\" name=\"mode\" value=\"1\">\r\n");// EDITAR/ Grabar, Agragar
   
strcat(buffer"        <input type=\"hidden\" name=\"what\" value=\"1\">\r\n");// Elemeto del PV-Anlage
   
strcat(buffer"     <p>Name PV:<input type=\"text\" name=\"namepv\" value=\"\">\r\n");
  
strcat(buffer"     <p>Max PI PV:<input type=\"text\" name=\"maxPIpv\" onkeypress=\"return validarn(event)\" value=\"\">\r\n");
  
//strcat(buffer, "        <input type=\"submit\">\r\n");
   
strcat(buffer"    <input type=\"Submit\" OnClick=\"validar();\" /></td></tr>");
   
strcat(buffer"        </form>\r\n");
    
strcat(buffer"        </td>\r\n");
   
strcat(buffer"        </tr>\r\n");
   
strcat(buffer"        </tr>\r\n");

      for(
0pv->pi_counti++)
   {
      
strcat(buffer"        <td>&nbsp;</td>\r\n");
      
strcat(buffer"       <tr>\r\n");
      
strcat(buffer"        <td>&nbsp;</td>\r\n");//
      
strcat(buffer"        <td>\r\n");
      
cgiPV_editPI(bufferpv->pi[i],i);
      
strcat(buffer"        </td>\r\n");
      
strcat(buffer"    </tr>\r\n");
   }
      
strcat(buffer"</table>\r\n");
      
strcat(buffer"        </body>\r\n");
      
strcat(buffer"        </html>");
}

void cgiPV_editPI(charbufferpowerinverter_t *piint pi_ID) {

    
int i 0;
   
char foo[10];
   
sprintf(foo"%d"pi_ID);
   
strcat(buffer"    <form>\r\n");
   
strcat(buffer"    <table class=\"powerinverter\">\r\n");
   
strcat(buffer"    <tr>\r\n");
   
strcat(buffer"    <th colspan=\"2\">POWERINVERTER\r\n");
   
strcat(buffer"    </th>\r\n");
   
strcat(buffer"    </tr>\r\n");
   
strcat(buffer"    <tr>\r\n");
   
strcat(buffer"    <td>&nbsp;</td>\r\n");
   
strcat(buffer"    <td>\r\n");
   
strcat(buffer"    <form method=\"get\">\r\n");
   
strcat(buffer"    <input type=\"hidden\" name=\"mode\" value=\"1\">\r\n");// EDITAR/ Grabar, Agragar
   
strcat(buffer"    <input type=\"hidden\" name=\"what\" value=\"2\">\r\n");// Elemeto del PV-Anlage
   
strcat(buffer"    <input type=\"hidden\" name=\"where\" value=\"");// es el ID de cada elemto cuando hay ma(MS
   
strcat(bufferfoo);//saber cual PI es
   
strcat(buffer"    \">\r\n");
   
strcat(buffer"  <p >Name PI:<input type=\"text\" name=\"namepi\" value=\"\">\r\n");
   
strcat(buffer"  <p >Serie PI:<input type=\"text\" name=\"seriepi\" value=\"\">\r\n");
   
strcat(buffer"  <p  >Min Volt PI:<input type=\"text\" name=\"minVpi\" value=\"\">\r\n");
   
strcat(buffer"  <p >Max Volt PI:<input type=\"text\" name=\"maxVpi\" value=\"\">\r\n");
   
strcat(buffer"  <p  >Max I PI:<input type=\"text\" name=\"maxIpi\" value=\"\">\r\n");
   
strcat(buffer"  <p >Max P PI:<input type=\"text\" name=\"maxPpi\" value=\"\">\r\n");
   
strcat(buffer"  <p>Max MPP pi:<input type=\"text\" name=\"maxMpppi\" value=\"\">\r\n");
   
strcat(buffer"        <input type=\"submit\">\r\n");
   
strcat(buffer"    </form>\r\n");
   
strcat(buffer"    </td>\r\n");
   
strcat(buffer"    </tr>\r\n");
   
strcat(buffer"    </tr>\r\n");
  for(
0pi->mpps_counti++) {
      
printf("maxmpp: %d\n",pi->mpps_count);
      
strcat(buffer"    <tr>\r\n");
      
strcat(buffer"        <td>&nbsp;</td>\r\n");//
      
strcat(buffer"        <td>\r\n");
      
cgiPV_editMPP(bufferpi->mpps[i],pi_IDi);
      
strcat(buffer"        </td>\r\n");
      
strcat(buffer"    </tr>\r\n");
   }
   
strcat(buffer"</table>\r\n");



Etiquetas: submit
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 13:21.