Advertisement

05.26.2008 at 08:53AM PDT, ID: 23432849
[x]
Attachment Details

extracting name value pair from the querystring in HTML document

Asked by jpking72 in CGI Scripting, Perl Programming Language, Miscellaneous Web Development

Tags: HMTL, Perl

I am writing a perl script that sends the parameter results from an HTML form to another HTML page.  What is the best way to extract the value for "id" in the "addedit.html" page?  I have shown what I am using below but it seems there should be a more efficient way to pass parameters.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
#!/usr/bin/perl
 
use strict;
use warnings;
use DBI;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);  # remove this when script goes into #production
 
my $query = new CGI;
my %formdata = $query->Vars;
my $cand = $formdata{'getcand'};
 
 
print "Location:http://www.mysite.com/addedit.html?id=$cand\n\n";
 
============addedit.html=================
 
<script type="text/javascript">
<!--
 
function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}
var canid = querySt("id");
 
Loading Advertisement...
 
[+][-]05.26.2008 at 11:39AM PDT, ID: 21647572

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.26.2008 at 03:58PM PDT, ID: 21648486

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.26.2008 at 11:11PM PDT, ID: 21649673

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: CGI Scripting, Perl Programming Language, Miscellaneous Web Development
Tags: HMTL, Perl
Sign Up Now!
Solution Provided By: marchent
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.26.2008 at 11:32PM PDT, ID: 21649757

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 07:16AM PDT, ID: 21652062

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.27.2008 at 09:21AM PDT, ID: 21653216

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628