[thelist] ASP Select Form not auto-selecting

James Aylard evolt at pixelwright.com
Fri Sep 26 09:59:48 CDT 2003


Rob,

> >Low and behold my output is:
> >92503 92503

    When I am testing the output of values, I typically wrap them within
brackets to know exactly where the value starts and ends, e.g.:

Response.Write "[" & strValue & "]<br>"

...and, since consecutive spaces presented within a browser (unless in a
<pre> block) will collapse into a single space, another trick is to replace
spaces with a tilde (or some other rarely used character), making it easier
to see (and, if necessary, count) the spaces, e.g.:

Response.Write "[" & Replace(strValue, " ", "~") & "]<br>"

    Obviously, trimming your values eliminates much of the need for these
techniques, although the second approach can still be helpful for capturing
multiple spaces within the interior of a value, which Trim() won't
eliminate.

> Casting request.form("Manager") as anything gave me a type mismatch error
>
> CInt(request.form("Manager"))  --->  Type mismatch
> Trim   (both) "" --->  Test still failed; no err
> CLng "" "" --->  Type mismatch
> CStr (both) "" --->  Test still failed; no err

    Then almost certainly your form value contains non-numeric characters or
is an empty string, neither of which can be cast as an integer or a long
number (in most cases). You didn't say that you did _both_ a trim and a
casting. I would suggest:

CStr(Trim(Request.Form("Manager")))

    Trimming first, casting _both_ values as strings, and then making a
simple string comparison in this case seems the best since it avoids
integer- and long-casting errors when your value contains nulls or
non-numeric characters. And I would also suggest assigning these values to
variables, especially if you are accessing a given value more than once!

James Aylard
evolt at pixelwright.com



More information about the thelist mailing list