473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

pass javascript array to perl CGI script

Please help!?
I am new to writing html, javascript, pretty new to MySQL but quite
proficient at writing Perl and i'm a quick learner.
I am building a database driven website and i am a little stuck:

I have page of results obtained from a MySQL query presented as a table (the
first column having checkboxes for each of the rows in the table, and all
having the name "seqs"). I have set up a javascript (connected to a "toggle
all" checkbox) that toggles the checked status of all the checkboxes in the
table. I have also included a submit button at the bottom of the table that
i would like connected to a javascript that passes document.hit_form.seqs as
an argument. Now this is what i want to do, but aren't sure how to go about
it:

i want to loop through the argument document.hit_form.seqs, and look to see
if it's checked by using:
for (i=0; i<argument document.hit_form.seqs.length; i++) {
if ( argument document.hit_form.seqs[i] == 1 ) {

}
}

If the checkbox is checked, i want to add the value associated with that
checkbox to an array (or comma seperated list - as a string).
I then what to pass the array/string to a cgi script, so i can use the
variable to query a MySQL database.
I then want the results to be saved to a file specified by the user via a
"save as" dialog box.

Please help!
Any pointer, would be very helpful!

Nathan
Jul 20 '05 #1
3 6768


Nath wrote:
I have page of results obtained from a MySQL query presented as a table (the
first column having checkboxes for each of the rows in the table, and all
having the name "seqs"). I have set up a javascript (connected to a "toggle
all" checkbox) that toggles the checked status of all the checkboxes in the
table. I have also included a submit button at the bottom of the table that
i would like connected to a javascript that passes document.hit_form.seqs as
an argument. Now this is what i want to do, but aren't sure how to go about
it:

i want to loop through the argument document.hit_form.seqs, and look to see
if it's checked by using:
for (i=0; i<argument document.hit_form.seqs.length; i++) {
if ( argument document.hit_form.seqs[i] == 1 ) {

}
}

If the checkbox is checked, i want to add the value associated with that
checkbox to an array (or comma seperated list - as a string).
I then what to pass the array/string to a cgi script, so i can use the
variable to query a MySQL database.
I then want the results to be saved to a file specified by the user via a
"save as" dialog box.


The usual way to pass values in a HTML form to a CGI script is by
submitting that form e.g.
<form action="yourperl.cgi"
method="POST">

<input type="checkbox" name="checkboxName" value="Kibology">
...
<input type="submit">
</form>
No script is needed, if the user clicks the submit button the checked
checkboxes are passed to the CGI as
checkboxName=value
pairs.
Why do you need or want anything else?
Of course JavaScript can change the value of a form control, for
instance if you want to pass JavaScript values to the CGI set up an
<input type="hidden" name="hiddenInput">
and sets its value
<form onsubmit="this.hiddenInput.value = arrayVar.toString();
return true;"

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Ok, maybe i'm off the mark totally (being new at this)...it seems obvious
when someone points it out to you! :o)

I'm not sure how to use the POST method, i've only used GET and i think the
number of name/value pairs will be too great...would you bee kind enoug to
give me a quick run through and/or links i might read?

Thanks
Nathan

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:3f********@olaf.komtel.net...


Nath wrote:
I have page of results obtained from a MySQL query presented as a table (the first column having checkboxes for each of the rows in the table, and all having the name "seqs"). I have set up a javascript (connected to a "toggle all" checkbox) that toggles the checked status of all the checkboxes in the table. I have also included a submit button at the bottom of the table that i would like connected to a javascript that passes document.hit_form.seqs as an argument. Now this is what i want to do, but aren't sure how to go about it:

i want to loop through the argument document.hit_form.seqs, and look to see if it's checked by using:
for (i=0; i<argument document.hit_form.seqs.length; i++) {
if ( argument document.hit_form.seqs[i] == 1 ) {

}
}

If the checkbox is checked, i want to add the value associated with that
checkbox to an array (or comma seperated list - as a string).
I then what to pass the array/string to a cgi script, so i can use the
variable to query a MySQL database.
I then want the results to be saved to a file specified by the user via a "save as" dialog box.


The usual way to pass values in a HTML form to a CGI script is by
submitting that form e.g.
<form action="yourperl.cgi"
method="POST">

<input type="checkbox" name="checkboxName" value="Kibology">
...
<input type="submit">
</form>
No script is needed, if the user clicks the submit button the checked
checkboxes are passed to the CGI as
checkboxName=value
pairs.
Why do you need or want anything else?
Of course JavaScript can change the value of a form control, for
instance if you want to pass JavaScript values to the CGI set up an
<input type="hidden" name="hiddenInput">
and sets its value
<form onsubmit="this.hiddenInput.value = arrayVar.toString();
return true;"

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3


Nath wrote:
Ok, maybe i'm off the mark totally (being new at this)...it seems obvious
when someone points it out to you! :o)

I'm not sure how to use the POST method, i've only used GET and i think the
number of name/value pairs will be too great...would you bee kind enoug to
give me a quick run through and/or links i might read?


If you know Perl CGI scripting you should know how to process POSTed
form data. As far as I know Perl has a CGI module that eases the task of
CGI programming with Perl, use that, it should be amply documented in
the Perl documentation:
http://www.perldoc.com/perl5.8.0/lib/CGI.html
JavaScript doesn't care about the method if you want to set the value of
a form control, you can do that with
document.forms.formName.elements.controlName.value = arrayVar.toString();

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tommo | last post by:
Hello All, I am a still learning so be easy on me. I am trying to get some code to work that is using JS and Perl/CGI, I am using AS Perl and an Apache Server on XP as the webserver. Can anyone...
13
by: Kevin | last post by:
Help! Why are none of these valid? var arrayName = new Array(); arrayName = new Array('alpha_val', 1); arrayName = ; I'm creating/writing the array on the server side from Perl, but I
4
by: Sunny | last post by:
Hi, I am at present working on a jsp page which has a single text field. Upon entering a value in the field, i am trigerring an onChangeEvent() which calls a method of javascript. I am also...
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
2
by: Augusto Cesar | last post by:
Hello people. How can I Pass ASP Array variable to Javascript; I´m to trying this: <script language="JavaScript"> var x = new Array(10);
2
by: pleaseexplaintome | last post by:
Hi I have the following perl/cgi script snippet. The goal of this script is to pass a javascript variable to perl where it can be re-used later. Any help is appreciated, Thanks ...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
1
by: bpejman | last post by:
Hi Everyone, I've been reading and searching the web for days trying to figure out how exactly you can access and read a Perl array or hash from within JavaScript. I've been reading that JSON is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.