For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > March 2006 > Perl CGI and Javascript









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Perl CGI and Javascript
Reshma

2006-03-29, 7:00 pm

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

xhoster@gmail.com

2006-03-29, 7:00 pm

"Reshma" <reshma.rr@gmail.com> 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
it_says_BALLS_on_your_forehead

2006-03-29, 7:00 pm


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

2006-03-29, 7:00 pm

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:[color=darkred]
> Reshma wrote:
>
> 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

2006-03-29, 7:00 pm


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="java script: submitform()">Search</A>
</form>
<SCRIPT language="JavaScript">
function submitform()
{
document.myform.submit();
}
</SCRIPT>

A. Sinan Unur

2006-03-29, 7:00 pm

"Reshma" <reshma.rr@gmail.com> wrote in
news:1143663296.178827.30850@v46g2000cwv.googlegroups.com:

> 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 <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmis...guidelines.html

Reshma

2006-03-29, 7:00 pm

This worked! Thank you very much for giving me the solution.

Tad McClellan

2006-03-29, 7:00 pm

Reshma <reshma.rr@gmail.com> 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
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com