passing variable's value from javascript and receiving in perl script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • satish2112
    New Member
    • Sep 2007
    • 6

    #1

    passing variable's value from javascript and receiving in perl script

    how can i pass a variable's value from javascript to perl script?
    how can i receive that value in the perl script?

    please help me!!!
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    You have to us a form to pass your javascript values to a perl script.

    Comment

    • satish2112
      New Member
      • Sep 2007
      • 6

      #3
      i am new to both javascript and perl script. can u please explain me with sample codes?

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Well, we are not able to help you with the javascript. You will have to go over to that forum. As far as the Perl part goes, you will need to learn Perl and also have to look up a tutorial on form processing with Perl. Google is your friend.

        Once you have some code and need help troubleshooting it, go ahead and post it here and we will help you.

        Regards,

        Jeff

        Comment

        • satish2112
          New Member
          • Sep 2007
          • 6

          #5
          thanks a lot! :)

          thanks and regards,
          satish

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            Originally posted by satish2112
            i am new to both javascript and perl script. can u please explain me with sample codes?

            This makes no sense to me. If you are new to javascript and perl how is it that you are asking this question? What are you trying to do or thinking?

            Comment

            • Kelicula
              Recognized Expert New Member
              • Jul 2007
              • 176

              #7
              What I would do is create a form element in the html page that has the javascript, and then you can grab it in perl with the CGI module. If you don't want the user to see it make it a hidden form element.

              If you wanted the persons first and last name to pass from javascript to perl
              Here is an example:

              [HTML]<html><head><ti tle>Title</title>

              <script language="javas cript" type="text/javascript">
              <!--

              function doIt(){

              var fname = document.theFor m.First.value() ;
              var lname= document.theFor m.Last.value();

              document.theFor m.flname.value= fname+" "+lname;

              }


              //->

              </head>
              <body>

              <form name=theForm method=get action=perlScri pt>

              <input type=hidden name=flname>
              Type your first name:
              <input type=text name=First>
              Type your last name:
              <input type=text name=Last>

              <input type=submit onclick="javasc ript:doIt();">

              </form>
              </body>
              </html>[/HTML]


              Then in perl:

              [CODE=perl]use CGI qw/:standard/;

              $name = param('flname') ;

              print $name;

              [/CODE]

              this should return (or more correctly display) their first and last name.
              The html, and javascript, and perl I wrote is very crude, but hey it's not my project right?

              You should get the idea...

              Comment

              Working...