Página 1 de 1

Botón de Opción y Evento Onclick - WWW::Mechanize

NotaPublicado: 2011-11-28 19:12 @842
por TooRDJ
¡Saludos!

Tengo una duda con un "Botón de Opción". La sintaxis sería:
Sintáxis: [ Descargar ] [ Ocultar ]
Using html4strict Syntax Highlighting
  1. <input type="radio" name="radio" id="radio" value="radio">
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4

Pero en mi caso, contiene el evento onclick():
Sintáxis: [ Descargar ] [ Ocultar ]
Using html4strict Syntax Highlighting
  1. <input id="givingLevel" type="radio" name="givingLevel" value="Other" onclick="rdo_OnClick(this);" />
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Estoy trabajando con "WWW::Mechanize". Envío el formulario con:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. $mech->submit('');
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4

Sin embargo, la opción de "givingLevel" no se activa :cry:

La respuesta, después del submit, la guardo en un html; al abrirlo, el formulario es enviado pero da el error de no haber seleccionado la opción "givingLevel".

He probado con:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. $mech->field('givingLevel' => 'Other');
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Y con:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. $mech->tick("givingLevel", "Other");
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Pero no funciona. :cry:

¡Agradezco la ayuda!

¡Gracias!

Re: Botón de Opción y Evento Onclick - WWW::Mechanize

NotaPublicado: 2011-11-28 19:54 @871
por explorer
Habría que saber qué hace el código JavaScript (ya que WWW::Mechanize no lo ejecutará), pero, aparte de eso, debería ser algo así:

$mech->field( 'givingLevel', 1, $numero );

siendo número el índice del objeto input de entre todos los radio que se llaman 'givingLevel', correspondiente al valor 'Other'.

De todas maneras, también debería funcionar según como lo has puesto...

¿Has ejecutado mech-dump sobre la página para ver qué te dice?


P.D. Ahora tengo dudas de si es un '1' o el valor indicado por el atributo value.
P.P.D. $numero es opcional... así que al final tenemos lo que ya tenías... lo siento.