Perl CGI and Javascript

Discussion in 'Perl Misc' started by Reshma, Mar 29, 2006.

  1. Reshma

    Reshma Guest

    I'm new to Perl CGI and Javascript.

    I have a page where there's a dropdown. When a user selects an item in
    the dropdown, it opens up a page (calling a CGI here). Since there's no
    button to click after the dropdown option is selected, on change of the
    dropdown item, I could call the CGI and pass the content only as a
    query string (GET request) or I could call an HTM page with a form as
    an intermediate step and onsubmit of the form have the CGI invoked
    (using POST request).

    When I call the CGI and pass content as query string, there's
    limitation in the length of the query string. it cannot exceed 1024
    characters. For me to use the post method, I need to have HTML form as
    the first screen.

    When I call the CGI upon selection of dropdown item, I'm able to access
    the content on the page where the dropdown is, on the CGI using
    javascript in the CGI script. Now, I need to pass the value of this
    javascript variable to a perl variable which performs other CGI
    functions.

    my var = 'Select HTML';

    $input_string = "var"; - is this possible?

    can some one tell me how I can achieve what I'm trying to do?

    Thanks
     
    Reshma, Mar 29, 2006
    #1
    1. Advertising

  2. Reshma

    Guest

    "Reshma" <> wrote:
    > I'm new to Perl CGI and Javascript.
    >
    > I have a page where there's a dropdown. When a user selects an item in
    > the dropdown, it opens up a page (calling a CGI here). Since there's no
    > button to click after the dropdown option is selected, on change of the
    > dropdown item, I could call the CGI and pass the content only as a
    > query string (GET request)


    I'm 70% sure that you can have javascript perform a POST submit in
    the on-change handler, without there be any visible form or submit button.
    I don't know how to do it, but I think it can be done. You should check a
    javascript, rather than a perl, resource for help with that.

    ....

    > When I call the CGI upon selection of dropdown item, I'm able to access
    > the content on the page where the dropdown is, on the CGI using
    > javascript in the CGI script.


    I can't figure out what this means. Or at least, if it means what it seems
    to mean, I'm pretty sure it is not true. Can you give an example?

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Mar 29, 2006
    #2
    1. Advertising

  3. Reshma wrote:
    > I'm new to Perl CGI and Javascript.
    >
    > I have a page where there's a dropdown. When a user selects an item in
    > the dropdown, it opens up a page (calling a CGI here). Since there's no
    > button to click after the dropdown option is selected, on change of the
    > dropdown item, I could call the CGI and pass the content only as a
    > query string (GET request) or I could call an HTM page with a form as
    > an intermediate step and onsubmit of the form have the CGI invoked
    > (using POST request).


    can't you write a javascript function that submits the form and then
    call it when the onchange event is fired?

    >
    > When I call the CGI and pass content as query string, there's
    > limitation in the length of the query string. it cannot exceed 1024
    > characters. For me to use the post method, I need to have HTML form as
    > the first screen.
    >
    > When I call the CGI upon selection of dropdown item, I'm able to access
    > the content on the page where the dropdown is, on the CGI using
    > javascript in the CGI script. Now, I need to pass the value of this
    > javascript variable to a perl variable which performs other CGI
    > functions.
    >
    > my var = 'Select HTML';
    >
    > $input_string = "var"; - is this possible?
    >
    > can some one tell me how I can achieve what I'm trying to do?
    >
    > Thanks
     
    it_says_BALLS_on_your_forehead, Mar 29, 2006
    #3
  4. Reshma

    Reshma Guest

    Hi,
    Can you please tell me how I can write a javascript to submit a form?

    I can try that.

    Thanks.

    it_says_BALLS_on_your_forehead wrote:
    > Reshma wrote:
    > > I'm new to Perl CGI and Javascript.
    > >
    > > I have a page where there's a dropdown. When a user selects an item in
    > > the dropdown, it opens up a page (calling a CGI here). Since there's no
    > > button to click after the dropdown option is selected, on change of the
    > > dropdown item, I could call the CGI and pass the content only as a
    > > query string (GET request) or I could call an HTM page with a form as
    > > an intermediate step and onsubmit of the form have the CGI invoked
    > > (using POST request).

    >
    > can't you write a javascript function that submits the form and then
    > call it when the onchange event is fired?
    >
    > >
    > > When I call the CGI and pass content as query string, there's
    > > limitation in the length of the query string. it cannot exceed 1024
    > > characters. For me to use the post method, I need to have HTML form as
    > > the first screen.
    > >
    > > When I call the CGI upon selection of dropdown item, I'm able to access
    > > the content on the page where the dropdown is, on the CGI using
    > > javascript in the CGI script. Now, I need to pass the value of this
    > > javascript variable to a perl variable which performs other CGI
    > > functions.
    > >
    > > my var = 'Select HTML';
    > >
    > > $input_string = "var"; - is this possible?
    > >
    > > can some one tell me how I can achieve what I'm trying to do?
    > >
    > > Thanks
     
    Reshma, Mar 29, 2006
    #4
  5. Reshma wrote:
    > Hi,
    > Can you please tell me how I can write a javascript to submit a form?
    >
    > I can try that.


    google it. the search phrase i used:
    javascript form submit

    click on the first link returned.

    <form name="myform" action="handle-data.php">
    Search: <input type='text' name='query'>
    <A href="javascript: submitform()">Search</A>
    </form>
    <SCRIPT language="JavaScript">
    function submitform()
    {
    document.myform.submit();
    }
    </SCRIPT>
     
    it_says_BALLS_on_your_forehead, Mar 29, 2006
    #5
  6. "Reshma" <> wrote in
    news::

    > Can you please tell me how I can write a javascript to submit a form?


    Could you please post your question to where it is relevant?

    comp.lang.javascript

    Sinan
    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Mar 29, 2006
    #6
  7. Reshma

    Reshma Guest

    This worked! Thank you very much for giving me the solution.
     
    Reshma, Mar 29, 2006
    #7
  8. Reshma <> wrote:

    > I'm new to Perl CGI and Javascript.



    I get the feeling that you do not yet grok the profound fundamental
    differences between the two.

    One of them executes on the web server, one of them executes
    on the web client (browser).


    > I have a page where there's a dropdown. When a user selects an item in
    > the dropdown, it opens up a page



    There is no "open up a page".

    There are only HTTP requests and responses.

    So: When a user selects an item in the dropdown, it generates
    a request...


    > (calling a CGI here).



    .... to a CGI program.


    > Since there's no
    > button to click after the dropdown option is selected, on change of the
    > dropdown item, I could call the CGI and pass the content only as a
    > query string (GET request)



    I doubt that that is true.


    > or I could call an HTM page with a form as
    > an intermediate step and onsubmit of the form have the CGI invoked
    > (using POST request).



    Surely Javascript can generate POST requests, can't it?

    (I dunno, this isn't a javascript newsgroup.)


    > When I call the CGI upon selection of dropdown item,



    When I call the interface upon selection of dropdown item,


    How the heck do you call an _interface_?

    (You don't. You can however, call a program that conforms to an interface.)

    So that should be:

    When I call the Perl program upon selection of dropdown item,


    > I'm able to access
    > the content on the page where the dropdown is, on the CGI using

    ^^^^^^^

    It sounds like you think that there is more than one CGI program
    involved, I don't think that is the case.


    > javascript in the CGI script. Now, I need to pass the value of this
    > javascript variable to a perl variable which performs other CGI
    > functions.



    > can some one tell me how I can achieve what I'm trying to do?



    Use Javascript to generate a POST request that contains whatever
    values you want it to contain.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Mar 30, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jürgen Exner

    Re: CGI Perl "use CGI" statement fail

    Jürgen Exner, Jul 31, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,622
    Jürgen Exner
    Jul 31, 2003
  2. praba kar

    Python-cgi or Perl-cgi script doubt

    praba kar, Jul 30, 2005, in forum: Python
    Replies:
    1
    Views:
    812
    Michael Sparks
    Jul 30, 2005
  3. excord80
    Replies:
    17
    Views:
    870
    J Kenneth King
    Jan 29, 2009
  4. shumsta
    Replies:
    1
    Views:
    304
    Fabian Pilkowski
    Jul 22, 2005
  5. kath
    Replies:
    4
    Views:
    814
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page