Hi JPDeni,
Back again, I'm trying to search in the length field, and using the mod you did for me earlier, the data is stored in 4 fields in the database as follows;
Length Unit Feet Meters
| 32 | Feet | 32 | 10.5 |
however trying to search has me stuck. I have
used your build_fancy_select_fields mod to create a range search with two select fields length-gt and length-lt , with a radio button field named unit with the values feet and meters.
This is the code you wrote to work out the feet/meters values given the other value:
if ($in{'Unit'} eq "Feet") {
$in{'Feet'} = $in{'Length'};
$in{'Meters'} = ($in{'Length'} / 3.048);
$in{'Meters'} = sprintf("%.1f",$in{'Meters'});
} else {
if ($in{'Unit'} eq "Meters") {
$in{'Meters'} = $in{'Length'};
$in{'Feet'} = ($in{'Meters'} * 3.048);
$in{'Feet'} = sprintf("%.1f",$in{'Feet'});
}
}
}
I know that when I search using this method it passes the unit value feet/meters although I don't want to search in only one field.
I need to search in two fields, meters/feet, the value stored in length is the same as which field is selected when it is entered eg: if someone enters 45 and selects from radio button meters,field length becomes 45.
Length Unit Feet Meters
| 45 | Meters | 138 | 45 |
The only real important fields for searching are feet/meters, do you know of any way to search both of these fields at once using a range search as I have set up.
Sorry I don't think I have explained it clearly, see what you think.
[This message has been edited by fordy (edited July 07, 1999).]
Back again, I'm trying to search in the length field, and using the mod you did for me earlier, the data is stored in 4 fields in the database as follows;
Length Unit Feet Meters
| 32 | Feet | 32 | 10.5 |
however trying to search has me stuck. I have
used your build_fancy_select_fields mod to create a range search with two select fields length-gt and length-lt , with a radio button field named unit with the values feet and meters.
This is the code you wrote to work out the feet/meters values given the other value:
Code:
if ($in{'Length'}) { if ($in{'Unit'} eq "Feet") {
$in{'Feet'} = $in{'Length'};
$in{'Meters'} = ($in{'Length'} / 3.048);
$in{'Meters'} = sprintf("%.1f",$in{'Meters'});
} else {
if ($in{'Unit'} eq "Meters") {
$in{'Meters'} = $in{'Length'};
$in{'Feet'} = ($in{'Meters'} * 3.048);
$in{'Feet'} = sprintf("%.1f",$in{'Feet'});
}
}
}
I know that when I search using this method it passes the unit value feet/meters although I don't want to search in only one field.
I need to search in two fields, meters/feet, the value stored in length is the same as which field is selected when it is entered eg: if someone enters 45 and selects from radio button meters,field length becomes 45.
Length Unit Feet Meters
| 45 | Meters | 138 | 45 |
The only real important fields for searching are feet/meters, do you know of any way to search both of these fields at once using a range search as I have set up.
Sorry I don't think I have explained it clearly, see what you think.
[This message has been edited by fordy (edited July 07, 1999).]