Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2007, 03:36 AM
Registered User
Join Date: Jul 2007
Location: London, , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginning ASP 3.0: changing text field to checkbox

OK, same project to re-purpose the Classifieds application in BEGINNING ASP 3.0 to a comicbook database ...

This is another brainteaser that should have been easy to resolve but just doesn't seem to work for me ... The original application includes a form page for editing the details of an "item". In my case the item is a comicbook. The page functions just fine as long as I stick with text fields, but I run into problems when I try to change a couple of the text fields into checkboxes.

So, here's the code of the Item.asp page with text fields:

  Dim blnNew
     ' detect whether the user is adding a new item or editing an existing one
  Select Case Request.QueryString("Action")
    Case "AddNew"
      blnNew = True
    Case "Edit"
      blnNew = False
  End Select


    <div id="fullwidth">
      If blnNew Then 
        Response.Write _ 
          "<center><h1>Add an issue to the database</h1></center>" & _
          "<center><p>Please add the following information for the issue you've just acquired</p> "
        Response.Write _ 
          "<center><h1>Edit data for issue you already have</h1></center>" & _
          "<center><p>Please edit the information for this item</p> "
        Dim rsItem 
        Set rsItem = Server.CreateObject("ADODB.Recordset")
        strSQL = "SELECT Title.titleName, Item.idItem, Item.issue, Item.[month], Item.[year], " & _
      " Item.cond, Item.gcdb, Item.image, Item.cents, Item.have, Item.want, Item.note " & _ 
      " FROM Title INNER JOIN Item ON Title.idTitle = Item.idTitle " & _
      " ORDER BY titleName,month;"

        rsItem.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText 
      End If

    <form action="addItem.asp" method="post">
  If blnNew Then %>
    <input type="Hidden" name="idItem" value=""> <%
  Else %>
    <input type="Hidden" name="idItem" value="<%= Request("Item") %>"> <%
  End If
<table border='0'>
    <td width=20% rowspan=8> </td>
    <td align="right">Title:</td>
    <td colspan="3"><input type="Text" name="titleName" 
          value="<% If Not blnNew Then Response.Write rsItem("titleName") End If%>"
          size="40" maxlength="75"></TD>
    <td align="right">Issue:</td>
    <td><input type="Text" name="issue" 
         value="<% If Not blnNew Then Response.Write rsItem("issue") End If%>"
    <td align="right">Condition:</td>
    <td><input type="Text" name="cond" 
         value="<% If Not blnNew Then Response.Write rsItem("cond") End If%>"
    <td align="right">Month:</td>
    <td><input type="Text" name="month" 
         value="<% If Not blnNew Then Response.Write rsItem("month") End If%>"
    <td align="right">Year:</td>
    <td><input type="Text" name="year" 
         value="<% If Not blnNew Then Response.Write rsItem("year") End If %>" 

    <td align="right">GCDB Page:</td>
    <td colspan="3"><input type="Text" name="gcdb" 
         value="<% If Not blnNew Then Response.Write rsItem("gcdb") End If%>"
    <td align="right">Image:</td>
    <td colspan="3"><input type="Text" name="image" 
         value="<% If Not blnNew Then Response.Write rsItem("image") End If%>"
    <td align="right">Cents:</td>
    <td><input type="Text" name="cents" 
         value="<% If Not blnNew Then Response.Write rsItem("cents") End If %>" 

    <td> </td>
    <td> </td>

    <td align="right">Have:</td>
    <td><input type="Text" name="have" 
         value="<% If Not blnNew Then Response.Write rsItem("have") End If %>" 

    <td align="right">Want:</td>
    <td><input type="Text" name="want" 
         value="<% If Not blnNew Then Response.Write rsItem("want") End If %>" 

    <td align="right">Notes:</td>
    <td colspan="3"><input name="note" type="text" 
    value="<% If Not blnNew Then Response.Write rsItem("note") End If %>" 
    <td> </td>
    <td align=center colspan=4><BR><%
      If Not blnNew Then %>
        <input type="Submit" name="Delete" value="Delete Item"><%
      End If %>

      <input type="Submit" 
         value="<% If blnNew Then %>Add New Item<% Else %>Update Item<% End If %>">

      <input type="Reset"></TD>
The object here is to create a dual-purpose page that can be used to add new items to the database and to edit existing items.

My problem arises when I try to change the "cents", "have" and "want" fields to checkboxes. This bit of code almost works:

    <td align="right">Cents:</td>
    <td><% If rsItem("cents") then strChecked = " checked" End If %>
    <input type="checkbox" name="cents" value="<%=rsItem("cents")%>"<%=strChecked%>>
    <td> </td>
    <td> </td>

    <td align="right">Have:</td>
    <td><% If rsItem("have") then strChecked = " checked" End If %>
    <input type="checkbox" name="have" value="<%=rsItem("have")%>"<%=strChecked%>>
    <td align="right">Want:</td>
    <td><% If rsItem("want") then strChecked = " checked" End If %>
    <input type="checkbox" name="want" value="<%=rsItem("want")%>"<%=strChecked%>>
(The variable "strChecked" is DIMmed further up the page!)

I say "almost" because it works fine (returns a checked checkbox when the related field in the database is checked) when I'm looking at an existing database entry, but it fails when I try to use it to add an entirely new item, with this error message:

Microsoft VBScript runtime  error '800a000d'

Type mismatch

/publishing/comics/collecting/admin/item2.asp, line 107
If anyone knows how to solve this problem, I'd be ever so grateful ...


Alan M, London
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
changing rs.field to records gilgalbiblewheel Classic ASP Databases 1 June 22nd, 2007 10:40 PM
checkbox control and bit field keyvanjan ASP.NET 1.0 and 1.1 Basics 2 September 6th, 2006 05:09 PM
Changing between bold and plain text in a text box funkybuddha Access 2 January 3rd, 2006 10:15 AM
Changing Checkbox Names deminpa Classic ASP Basics 1 August 4th, 2005 06:03 PM

All times are GMT -4. The time now is 06:03 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.