i'm pulling my hair out. i'm sure this will be obvious to someone else. i'm using the multiple default sort hack where i have 3 sortfields and sortorders in my cfg file named $sortfield1, $sortfield2... $sortorder1...
i want to list them showing the fieldname or number and the order (ascending/descending). of course i want to be efficient and not list each one in the code but use a variable to increment them 1, 2, 3. and there's the rub! i've tried numerous things and none have worked completely. this is what i have now but none of it works. if i don't use a variable but just put $sortfield1 and $sortorder1 i can get it to work just fine. but i wanted to learn to do it right in case i need something similar with 20 variables instead of just 3.
thanks!
my ($i) = 1;
while ($i < 4) {
$sortname = "sortfield" . $i;
print qq|<tr><td>$sortname</td><td>$sortfield</td></tr>
<TR><TD ALIGN="Right" WIDTH=40%>
<SELECT NAME="$sortname"><OPTION SELECTED>$sortfield$i<OPTION>---
|;
foreach $field (@db_cols) {
print qq|<OPTION>$field|; # this lists the choices of field names and works fine
}
print qq|
</SELECT></TD>
<TD WIDTH=60%>|;
if ($sortorder1 eq "ascend" ) { $acheck="checked"; $dcheck="" } else { $acheck=""; $dcheck="checked"; }
$order = "sortorder" . $i;
if ($order eq "ascend" ) { $acheck="checked"; $dcheck="" } else { $acheck=""; $dcheck="checked"; }
print qq|<INPUT TYPE="radio" name="$order" value="ascend" $acheck>Ascending
<INPUT TYPE="radio" name="$order" value="descend" $dcheck>Descending </TD></TR>
|;
$i++;
}
i want to list them showing the fieldname or number and the order (ascending/descending). of course i want to be efficient and not list each one in the code but use a variable to increment them 1, 2, 3. and there's the rub! i've tried numerous things and none have worked completely. this is what i have now but none of it works. if i don't use a variable but just put $sortfield1 and $sortorder1 i can get it to work just fine. but i wanted to learn to do it right in case i need something similar with 20 variables instead of just 3.
thanks!
my ($i) = 1;
while ($i < 4) {
$sortname = "sortfield" . $i;
print qq|<tr><td>$sortname</td><td>$sortfield</td></tr>
<TR><TD ALIGN="Right" WIDTH=40%>
<SELECT NAME="$sortname"><OPTION SELECTED>$sortfield$i<OPTION>---
|;
foreach $field (@db_cols) {
print qq|<OPTION>$field|; # this lists the choices of field names and works fine
}
print qq|
</SELECT></TD>
<TD WIDTH=60%>|;
if ($sortorder1 eq "ascend" ) { $acheck="checked"; $dcheck="" } else { $acheck=""; $dcheck="checked"; }
$order = "sortorder" . $i;
if ($order eq "ascend" ) { $acheck="checked"; $dcheck="" } else { $acheck=""; $dcheck="checked"; }
print qq|<INPUT TYPE="radio" name="$order" value="ascend" $acheck>Ascending
<INPUT TYPE="radio" name="$order" value="descend" $dcheck>Descending </TD></TR>
|;
$i++;
}