Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 743
  • Last Modified:

ASP / ubound "Type mismatch"

I try to run my script which keeps coming up with an error "Type mismatch: 'ubound'"  not sure why it gives this error.  The array string is coming from a variable definition statement.  ubound it is supposed to parse the array. This code is part of a form and it is supposed to populate the drop down box once it displays on the web.

example:

stateAbbr="MO,MN...etc"

<select name="st">
              <option />
              <% for x = 0 to ubound(stateAbbr)
                   Response.Write("<option value=""" & stateAbbr(x) & """")
                       'if option is same as search parameter, pre-select it
                         if stateAbbr(x) = st then Response.Write(" selected=""selected""")
                         Response.Write(">" & stateAbbr(x) & "</option>")
                     next                         
                %>
            </select>

let me know if there is anything different that I should be putting in the code.  Thanks
0
skyler99
Asked:
skyler99
4 Solutions
 
Harisha M GCommented:
Hi,

Try this:

stateAbbr=Array("MO","MN",...)

instead of

stateAbbr="MO,MN...etc"




---
Harish
0
 
Arthur_WoodCommented:
also:

if stateAbbr(x) = st then Response.Write(" selected=""selected""")

should read:

if stateAbbr(x) = st then Response.Write(" selected")


the resulting HTML will look something like this:


<select name = "st">
    <option value = "AZ">AZ
    <option value = "CA" selected>CA
</select>

and the choice of CA will be the selected option in the DropDown.

AW

0
 
Kevin CrossChief Technology OfficerCommented:
In XHTML, all tags must be closed and attributes must be in format name="value", so think how it is stated previously is correct.
0
 
Kevin CrossChief Technology OfficerCommented:
there are silly ones like selected and noshade that you have to say selected="selected" or noshade="noshade" :) but it is right, Arthur
0
 
purfusCommented:
In XHTML all parameters have to have a value.  More to the point its fixing some of the loose code from HTML.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now