Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 2nd, 2007, 04:36 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Listboxes and Checkboxes

I have the following code:
---
 Option Explicit

    Dim bValid, sErrorMsg, iListCount
    Dim aList(4)

    bValid = true
    iListCount = 0

    If Request.Form("rt").Count = 0 Then
        bValid = false
        sErrorMsg = "Please Select a Request Type <br /> "
    Else
        For iListCount = 0 To Request.Form("rt").Count
            If Request.Form("rt").item(iListCount) = "on" Then
                aList(iListCount) = "Checked"
            End If
        Next
    End If


    If Len(Request.Form("policynumber")) < 10 Then
        bValid = false
        sErrorMsg = sErrorMsg & "Enter Policy Number in Format AAA1111111 <br /> "
    End If
---

When I run the code with the web page I get the error Request object, ASP 0105 (0x80004005)
An array index is out of range.
It Points to the line
If Request.Form("rt").item(iListCount) = "on" Then

At this point I'm stuck. I've tried the get method instead of post, I've tried using htmlencode, but I always get the same error.

Any Suggestions

 
Old January 2nd, 2007, 04:37 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've also tried it with
If Request.Form("rt")(iListCount) = "on" Then

instead of

If Request.Form("rt").item(iListCount) = "on" Then

with the same results.

 
Old January 2nd, 2007, 05:28 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Since I couldn't figure out the error, I created a work around with some inspiration from another forum.

<% Option Explicit %>
<%
    Dim bValid, bReqValid, sErrorMsg, sReqList, iCheckCount
    Dim aList(4)

    bValid = true
    bReqValid = false

    For iCheckCount = 0 to 4
        If Request.Form("rt"&iCheckCount) <> "" Then
            aList(iCheckCount) = "Checked"
            sReqList = SReqList & "<br>" & Request.Form("rt"&iCheckCount)
            bReqValid = true
         End If
    Next
    If bReqValid = false Then
        sErrorMsg = "Please Select a Request Type <br /> "
    End If

    If Len(Request.Form("policynumber")) < 10 Then
        bValid = false
        sErrorMsg = sErrorMsg & "Enter Policy Number in Format AAA1111111 <br /> "
    End If
 %>






Similar Threads
Thread Thread Starter Forum Replies Last Post
getting Listboxes to communicate susan_ny ASP.NET 2.0 Basics 1 January 26th, 2006 11:41 PM
Listboxes Sub-Listboxes and Table Linking MJB05 Access 4 September 20th, 2005 12:37 PM
Listboxes with validation mlf VB.NET 2002/2003 Basics 0 March 2nd, 2005 11:42 PM
ListBoxes problems MixedCode General .NET 1 October 25th, 2004 10:48 AM
Listboxes Alaric VS.NET 2002/2003 1 October 29th, 2003 11:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.