Perl CGI and Javascript

R

Reshma

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
 
X

xhoster

Reshma said:
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
 
I

it_says_BALLS_on_your_forehead

Reshma said:
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?
 
R

Reshma

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

I can try that.

Thanks.
 
I

it_says_BALLS_on_your_forehead

Reshma said:
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>
 
T

Tad McClellan

Reshma said:
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top