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

    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?

    Reshma, Mar 29, 2006
    1. Advertisements

  2. Reshma

    xhoster Guest

    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.

    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?

    xhoster, Mar 29, 2006
    1. Advertisements

  3. can't you write a javascript function that submits the form and then
    call it when the onchange event is fired?
    it_says_BALLS_on_your_forehead, Mar 29, 2006
  4. Reshma

    Reshma Guest

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

    I can try that.

    Reshma, Mar 29, 2006
  5. 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>
    <SCRIPT language="JavaScript">
    function submitform()
    it_says_BALLS_on_your_forehead, Mar 29, 2006
  6. Could you please post your question to where it is relevant?


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

    comp.lang.perl.misc guidelines on the WWW:
    A. Sinan Unur, Mar 29, 2006
  7. Reshma

    Reshma Guest

    This worked! Thank you very much for giving me the solution.
    Reshma, Mar 29, 2006

  8. 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).

    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...

    .... to a CGI program.

    I doubt that that is true.

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

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

    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,


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

    Use Javascript to generate a POST request that contains whatever
    values you want it to contain.
    Tad McClellan, Mar 30, 2006
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.