aurora26 has asked for the wisdom of the Perl Monks concerning the following question:

hi i used onClick event of a button in a cgi script as shown below... $q->button(-name=>'add_details',-id=>"button_id",-value=>"button_val",-onClick=>"Update_database()"); but its not working as expected....the function is not calling when i clicked on that button

Replies are listed 'Best First'.
Re: (OT) onClick event in cgi not workling
by marto (Cardinal) on Apr 05, 2012 at 09:23 UTC

    Ensure you don't have a JavaScript problem, essentially remove Perl from the equation by testing that the HTML it generates works. Use something like FireBug to debug. Consider using templates (HTML::Template, Template::Toolkit) to seperate your perl code and HTML/CSS/JS.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: (OT) onClick event in cgi not workling
by tobyink (Canon) on Apr 05, 2012 at 11:46 UTC

    but its not working as expected

    Really? It's working exactly how I'd expect it to (i.e. not at all). If it's not working how you'd expect it to, then change your expectations.

    Go back to square one. Learn how the Web works. In particular pay attention to the distinction between client-side and server-side scripting.

    Think of it this way. My name is Mr Server; your name is My Browser. We live in different towns. We can talk on the telephone, but if I'm eating a bacon sandwich while we're talking, you can't smell it.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: (OT) onClick event in cgi not workling
by choroba (Cardinal) on Apr 05, 2012 at 09:45 UTC
    What kind of beast this Update_database is? Is it a javascript function?
      no its just a perl function
        The code specified in an onClick event is not Perl code. Perk runs on the server, for client-side scripting, Javascript is usually used.
Re: (OT) onClick event in cgi not workling
by Anonymous Monk on Apr 06, 2012 at 00:07 UTC