I have a project in which i have an html page.There I have a Submit Button using which i have to call a perl subroutine, carry out some function and return the value. The problem is that i am not able to pass the value to the subroutine. Also is there a way to use $_Get or $_Post i n perl??

I am posting my script below

#!/usr/bin/perl -w use CGI::Ajax; use CGI; sub functions { my $Fn = $_Get['Function']; my $input = shift; if(1) { return ("True"); } if(0) { return ("False"); } } sub Show_HTML { my $html = <<EOT; <HTML> <HEAD><title>Perl and HTML</title> </HEAD> <BODY> <script type="text/javascript"> function CheckIsNumeric() { var AsciiCode = event.keyCode; if ((AsciiCode < 48) || (AsciiCode > 57)) { alert('Please enter only numbers.'); event.cancelBubble = true; event.returnValue = false; } } </script> <Form method="Get"> <select name="Function"> <option value="0" selected>(please select:)</option> <option value="1">Func1</option> <option value="2">Func2</option> </select> &nbsp; &nbsp; Enter a number:&nbsp; <input type="text" name="Number" id="myText" size="6"onkeypress =" +CheckIsNumeric()"/> &nbsp; &nbsp; Enter a function:&nbsp; <input type="text" name="fns" id="URI" size="25"> <input type='Submit' onsubmit="functions('fns');" value='Submit' / +> </Form> <hr> <div id="resultdiv"> </div> <br> </BODY> </HTML> EOT return $html; } my $cgi = new CGI(); my $pjx = new CGI::Ajax( 'functions' => \&functions ); print $pjx->build_html($cgi,\&Show_HTML);
what i want to do is pass the fns's value to the subroutine and return a value.

Kindly Help. Thanx in advance.


In reply to Perl in HTML by Appy16

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.