passing variable using javascript (was: ashers)

They have: 5,633 posts

Joined: Jan 1970

Hi,
The cgi page before this has this part on the form to carry through the variable from the previous html page:-

#print startform(-method=>'GET', -action=>'/cgi/book_receipt.cgi', -onsubmit=>'this.search = location.search; return validateOrder(this);');
print startform(-method=>'GET', -action=>'/cgi/router2.cgi', -onsubmit=>'this.search = location.search; validateOrder(this);');

This then goes to the router page, I need the following piece of javascript to go into the router2.cgi page:-

<script LANGUAGE="javascript">

var prefix = "\r\n"
if (window.location.search.length>1){

var seaStr = window.location.search.substring(1,
window.location.search.length);

document.write (prefix + seaStr + suffix);
document.write ("");
}
</script>

The cgi page is as follows:-

#!/usr/local/bin/perl
use CGI qw(:standard);
use Time::localtime;

sub GetOrderNumber {
#
# Gets the next order number from the OrderConfig file
#
my $OrderConfig = "order.cfg";
my $OrderTemp = "order.tmp";
my $OrderBackup = "order.bak";
my $OrderNumber = "";

open(OLD, "<$OrderConfig");
open(NEW, ">$OrderTemp ");
while ( ) {
chomp;
$OrderNumber = $_;
print NEW $OrderNumber + 1;
}
close(NEW);
close(OLD);
rename($OrderConfig, $OrderBackup);
rename($OrderTemp, $OrderConfig);
return $OrderNumber;
} # end of GetOrderNumber

##################################################
##########
##### Start here
##################################################
##########

# Get an order number
$OrderNumber = GetOrderNumber;

# Add it to the parameters
param("ordernumber", $OrderNumber);

# Get a timestamp
$tm = localtime;
$Timestamp = sprintf("%02d/%02d/%04d %02d:%02d:%02d", $tm->mday, $tm->mon+1, $tm->year+1900, $tm->hour, $tm->min, $tm->sec);

# Add it to the parameters
param("timestamp", $Timestamp);

# Save all the data to disc
open(ORDER, ">orders.dat");
save_parameters(*ORDER);
close(ORDER);

# If this is a credit card order we go for the credit card details
if (param("PaymentMethod") eq "Credit Card") {
print redirect(-URL=>'https://www.secure-server.co.uk/forms/SS0682.cfm?ordernumber=' . $OrderNumber)
}
else {
print redirect(-URL=>'book_receipt.cgi?ordernumber=$OrderNumber')
}

Any ideas, I need this to pick up the variable so it passes on to the next page. Hope this makes sense, the url is vetstream.co.uk/donaldsonandpartners/, if you click on the book shop button, this is where im trying to carry through the stylesheet into the cgi.
Thanks