I'm trying to figure out how to pass those variables to an HTML page. A portion of the script is as follows:
____________________________________________
#!/usr/bin/perl
$lib="../lib";
require "$lib/config.pl";
# Pull in required libraries
require "$lib/dbmember.pl";
require "$lib/dbcompany.pl";
require "$lib/ez_html.pl";
require "$lib/web_basic.pl";
# Global variables
# Read in form data
%in=&Get_Form_Data;
# Validate login
&OpenMemberDB;
&Login;
&OpenCompanyDB;
%fields = &LoadMember( $in{'login key'} );
%sponsor_fields = &LoadMember( $fields{'parent'} );
foreach $traffic_prog (keys %def_tkey)
{
$sponsor_fields{$traffic_prog}=$def_tkey{$traffic_prog}
unless $sponsor_fields{$traffic_prog};
}
____________________________________________
This code is from a CGI script that generates an HTML page. My goal is to use the $sponsor_fields{$traffic_prog} variable in the called HTML page as follows:
[myss.sitesell.com...]
I've been told that this can be done through JavaScript. I'm not a programmer and I feel alot more comfortable working with JavaScript than CGI.
This is the last piece of the puzzle before I can launch my site. To see exactly what I'm trying to do, please go to <snip> and look at the right frame. I'm trying to populate each of the books in that frame with a member's ID.
Can you help me?
Paul Cordle
p.s. The script is a modified version of the "LifeStyleNetworker Special Edition" and my site is on ThirdSphereHosting.
(edited by: Brett Tabke)
Well, all you have to do is pass the variables on to the HTML page in a query string. Say that you want to pass the word foobar on to foo.html
Simply have the Perl script open foo.html?foobar
print "Location: path_to_page/foo.html?foobar\n\n"; In foo.html you need the following JavaScript:
<script language="javascript" type="text/javascript">
var thestring = location.search.substring(1);
</script>
Now, the variable
thestring contains foobar. Whenever you want to use it, for example in a URL, use the JavaScript function document.write <script language="javascript" type="text/javascript">
document.write('<a href="' + thestring + '.html"'>Link text</a>);
</script>
However, if the HTML page is entirely generated by the Perl script (not opened using the
print "Location: path_to_page/foo.html?foobar\n\n"; construct) it is even easier. Whereever you want the value to appear, enter the variable name (in the Perl code, the Perl generated HTML section).
Example:
<a href="$sponsor_fields{$traffic_prog}.html">Link text</a>
You can even use a combination of the two:
<a href="foobar.html?$sponsor_fields{$traffic_prog}.html">Link text</a>
When the page is rendered, $sponsor_fields{$traffic_prog} will be replaced with whatever value it has.
I hope this helps. I'm sorry I didn't notice your post earlier.