Though I'd strongly recommend using a font whose characters are all of equal width (Courier New, perhaps) and then just multiplying the string length by the width you determine one character to have, you could use a bit of server-side code to do the trick. I'll be speaking in PHP from here on. : )
Assming you have access to the GD library, you can use the imagettfbbox() function to return the coordinates of the bounding box of the string; following is an example:
<?php
$size = 15;
$angle = 0;
$path = 'name_of_font.ttf';
$bounding = imagettfbbox($size, $angle, $path, "This is some text.");
// $bounding is now an array of values that contain
// information regarding the invisible "box" around
// the text; the only element you're really interested
// in, though, the one that will tell you the width of
// the text, is $bounding[2]
?>
So, whenever you need to deduce the width of a string, simply call this function and use the element at index 2 of the resultant array to get the information you need. Hope I've helped.