Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How a HTML radio button on click calls a CGI function?

by Erez (Curate)
on Dec 17, 2008 at 11:22 UTC ( #730897=note: print w/ replies, xml ) Need Help??


in reply to How a HTML radio button on click calls a CGI function?

Plz suggest me a suitable code so that when i click on the 32bits value radio button it will call the subroutine 32bits_value()

You need to make a distinction here. While clicking on the radio button is a client-side event, the actual function lies on the server.
In order for a client-side event to trigger a server action, you need to send a request to the server (aka Postback request). There are several ways of doing that, from reloading the whole page, to a specific AJAX call (which won't load the whole page).

However, If I'm reading your question right, there shouldn't be any actual call to the server, since you can run the calculations client-side via JavaScript.

"A core tenant of the greater Perl philosophy is to trust that the developer knows enough to solve the problem" - Jay Shirley, A case for Catalyst.


Comment on Re: How a HTML radio button on click calls a CGI function?
Re^2: How a HTML radio button on click calls a CGI function?
by sanjay nayak (Sexton) on Dec 18, 2008 at 11:39 UTC

    Hi
    Thanks for the reply.
    #!C:\Perl\bin\perl.exe -w use strict; use CGI; # or any other CGI:: form handler/decoder use CGI::Ajax; my $cgi = new CGI; my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func ); print $pjx->build_html( $cgi, \&Show_HTML); sub perl_func { my $input = shift; # do something with $input my $output = $input . " was the input!"; return( $output ); } sub Show_HTML { my $html = <<EOHTML; <HTML> <BODY> Enter something: <input type="text" name="val1" id="val1" onkeyup="exported_func( ['val1'], ['resultdiv'] );"> <br> <div id="resultdiv"></div> </BODY> </HTML> EOHTML return $html; }

    When i want to compile this code , it gives a error "Can't find string terminator "EOHTML" anywhere before EOF at ajay.pl line 19.". Plz suggest why this error comes?

    Regd's
    Sanjay

      You probably have whitespace in front of the EOHTML string terminator. Delete anything (tabs, spaces) before it, or better yet, use the CGI methods to generate the html for you.

      "A core tenant of the greater Perl philosophy is to trust that the developer knows enough to solve the problem" - Jay Shirley, A case for Catalyst.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://730897]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-12-23 00:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (133 votes), past polls