[thelist] ASP Select Form not auto-selecting

Wade Armstrong wade at wadearmstrong.com
Thu Sep 25 21:06:55 CDT 2003


On 9/25/03 Rob Smith <rob.smith at THERMON.com> wrote:

>Hi list
>
>If you've ever created a form that submits to itself for form
validation
>before proceeding on, this is for you. Mine has a drop-down menu that, 
>if
>there's something wrong with the form, would auto select whatever WAS
>originally selected:
>
>response.write request.form("Manager") & " "
>Managers.fields.item("RepID").value
>
>Low and behold my output is:
>92503 92503
>
>Yet... the test to compare these two to enable the "selected" feature,
>fails.

The problem is probably with VBScripts loosely-typed nature.

<tip type="ASP/VBScript">
When comparing values in VBScript, always make sure to cast your
variables as the right datatype. Comparing numbers? Try CInt() or
CLng(). Comparing strings? Try CStr(). You never know when VBScript
thinks the number 47 is actually the string "47".
</tip>


More information about the thelist mailing list