ASP / ubound "Type mismatch"

Posted on 2006-05-26
Last Modified: 2008-01-09
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.



<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>")

let me know if there is anything different that I should be putting in the code.  Thanks
Question by:skyler99
    LVL 37

    Accepted Solution


    Try this:


    instead of


    LVL 44

    Assisted Solution


    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

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


    LVL 59

    Assisted Solution

    by:Kevin Cross
    In XHTML, all tags must be closed and attributes must be in format name="value", so think how it is stated previously is correct.
    LVL 59

    Expert Comment

    by:Kevin Cross
    there are silly ones like selected and noshade that you have to say selected="selected" or noshade="noshade" :) but it is right, Arthur
    LVL 3

    Assisted Solution

    In XHTML all parameters have to have a value.  More to the point its fixing some of the loose code from HTML.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now