tags:

views:

150

answers:

3

I have designed one sign-up form,in this form after getting all necessary values I will click submit button.

And while clicking that submit button I want to call one function and I want to pass the arguments to that function.

I have written code for this purpose,but the function is called first before getting the details.(i.e)after getting the details in sign-up form I need to pass these values to one function and I need to validate those values.

But what happened was,before getting the details the function get called.

A: 

Sounds like a vwait problem. Check in the Perl/Tk documentation for:

$widget->waitVariable(varRef)

In this way you are sure your code is only executed when the wait variable is modified (that's when you click the "submit" button)

Hope it helps.

Carlos Tasada
+3  A: 

Carlos's suggestion is one way. Another is to put a command callback on the button that reads the values out of the form and calls your function, perhaps like this.

$button->configure(-command => sub { yourFunc($var1, $var2); });

I'm assuming you've bound the fields of the form to the variables $var1 and $var2 here; modify to fit your own situation of course.

Donal Fellows
Thank you very much.
kiruthika
+2  A: 

You have a number of options when specifying a code ref and arguments to a bind to a widget:

$w->configure( -command => [ \&subname,   @args ... ]             );
$w->configure( -command => [ sub { ... }, @args ... ]             );
$w->configure( -command => [ 'methodname', $invocant, @args ... ] );
$w->configure( -command => [ $invocant, 'methodname', @args ... ] );

See the Tk::callbacks POD for more info.

daotoad