Click to See Complete Forum and Search --> : pl script printing blank lines


dvaughan
03-26-2003, 11:51 AM
Hi. I have a script that takes values from a form and emails them to a specific user. Works fine, but when I view the email output I see that when an item is not checked it prints a blank space in it's place. So there could be several blank lines between selected items. Looking at the script I see why it does this, but figured there must be a way to NOT print a blank line when an object is not selected. Here's a portion of the code i have:

$PP_ck1 = $in{'PP_ck1'};
$PP_ck2 = $in{'PP_ck2'};
$PP_ck3 = $in{'PP_ck3'};
$PP_ck4 = $in{'PP_ck4'};
$PP_ck5 = $in{'PP_ck5'};

print MAIL "PRODUCT PAGES\n";
print MAIL "$PP_ck1\n";
print MAIL "$PP_ck2\n";
print MAIL "$PP_ck3\n";
print MAIL "$PP_ck4\n";
print MAIL "$PP_ck5\n";
print MAIL "---------------------------------\n";

Thanks in advance for any observations.

khalidali63
03-26-2003, 03:25 PM
I dont think there will be a straight forward answer to this.
Since when you click submit,the browsers know how to send data of a form using HTTP protocol.And typically an http request contains all the data + elements in a form with it.
So if you do not want some elements to be sent with the request you may have to create a work around,
E.G
delete the elements which are empty right before you complete the submit.

Now the above is just an idea and I havent even tried it.

Cheers

Khalid

Scriptage
03-27-2003, 09:33 AM
It's simple:

$PP_ck1 = $in{'PP_ck1'};
$PP_ck2 = $in{'PP_ck2'};
$PP_ck3 = $in{'PP_ck3'};
$PP_ck4 = $in{'PP_ck4'};
$PP_ck5 = $in{'PP_ck5'};

print MAIL "PRODUCT PAGES\n";
if(defined $PP_ck1){
print MAIL "$PP_ck1\n";
}
if(defined $PP_ck2){
print MAIL "$PP_ck2\n";
}
if(defined $PP_ck3){
print MAIL "$PP_ck3\n";
}
if(defined $PP_ck4){
print MAIL "$PP_ck4\n";
}
if(defined $PP_ck5){
print MAIL "$PP_ck5\n";
}
print MAIL "---------------------------------\n";

dvaughan
03-27-2003, 12:13 PM
Thanks Scriptage! Worked like a charm.

Scriptage
03-28-2003, 07:02 PM
no problem ;)