Wrox Programmer Forums
|
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4
This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040
Please indicate which version of the book you are using when posting questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 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 August 16th, 2005, 08:44 AM
Authorized User
 
Join Date: Jul 2003
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default CInt Error Beginning DW MX Book

Chapter 9 dropdown menu. I've tried download code and get same error.
Please help.
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CInt'
/thesoccersite/events.asp, line 14
Code:
<%
   Dim sSelected    
   Dim iLastCategory
  If Request.QueryString("lstCategory") <> "" Then
    ' Category has been chosen, so let's save it in a cookie
    iLastCategory = Request.QueryString("lstCategory")
    Response.Cookies("LastCategory") = iLastCategory
    Response.Cookies("LastCategory").Expires = Date() + 10
  Else
    ' Page is requested directly, so get the cookie
    If Len(Request.Cookies("LastCategory")) > 0 Then
      iLastCategory = CInt(Request.Cookies("LastCategory"))  
    End If
  End If
%>

<form action="events.asp" method="get" name="frmSelectCategory">
    <select name="lstCategory" onChange="document.frmSelectCategory.submit();">
       <option value="">Select a Category</option>
         <% If iLastCategory = 1 Then sSelected = " selected=""selected""" _
         Else sSelected = ""%>
          <option value="1"<%=sSelected%>>Champions League</option>
       <% If iLastCategory = 2 Then sSelected = " selected=""selected""" _
         Else sSelected = ""%>
         <option value="2"<%=sSelected%>>UEFA Cup</option>
       <% If iLastCategory = 3 Then sSelected = " selected=""selected""" _
         Else sSelected = ""%>
         <option value="3"<%=sSelected%>>National League</option>
       <% If iLastCategory = 4 Then sSelected = " selected=""selected""" _
         Else sSelected = ""%>
         <option value="4"<%=sSelected%>>US Major League Soccer</option>
        </select>
    </form>
      <%   Select Case iLastCategory 
       Case 1 ' Champions League
       Response.Write("<h3>Champions League</h3>") %>  
       <p>Competition for the leading clubs in Europe.</p> 
       <p>The top placed teams from every European county make up a 
       competition with 2 league stages, the winners going through to 
       play in the semi-finals over home and away matches, and the final
       at a stadium somewhere in Europe.</p>
       <p>Can <b>Peterborough United</b> of England retain the title they deservedly 
       won after a penalty shoot out in last years competition against 
       <b>Ajax</b> from the Netherlands?</p>

      <%   Case 2 ' UEFA Cup
       Response.Write("<h3>UEFA Cup</h3>")   %>  
       -- HTML Content for UEFA Cup Events here --

      <%   Case 3 ' National League
       Response.Write("<h3>National League</h3>") %>  
       -- HTML Content for National League Events here --

      <%   Case 4 ' US Major League Soccer
       Response.Write("<h3>US Major League Soccer</h3>") %>  
       -- HTML Content for US Major League Soccer Events here --

      <%   Case Else ' No category chosen   %>  
       Please select a Category from the drop-down list.

      <%   End Select   %>


 
Old August 16th, 2005, 08:54 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It looks like this is causing the error:

 If Len(Request.Cookies("LastCategory")) > 0 Then
     iLastCategory = CInt(Request.Cookies("LastCategory"))
   End If

What did you store in the LastCategiry cookie? It seems it cannot convert it to an Integer.

Try this to find out what's inside the cookie:

Response.Write("Cookie has a value of " & Request.Cookies("LastCategory"))

Do you see a number?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old August 16th, 2005, 09:23 AM
Authorized User
 
Join Date: Jul 2003
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I understand what your saying. when I get home I will check that.

Thanks!
Rich

 
Old August 16th, 2005, 05:37 PM
Authorized User
 
Join Date: Jul 2003
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get the same error. Any other ideas?

Thanks!
Rich

 
Old August 16th, 2005, 08:02 PM
Authorized User
 
Join Date: Jul 2003
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help Imar.

I cleaned the cookies off of my browser and it works fine.

Is it possible that I had written the cookie incorrectly and that cookie remained in cache. ( since I had expire set to 10 days) The whole time I'm testing I'm pulling information from the badly formed cookie? So I correctly write the cookie and now the clean cache grabs the new cookie and the function works?

Sound likely??


 
Old August 17th, 2005, 02:30 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, that's exactly what I think happened. If you store a bad cookie and then try to convert it to an Int, you'll get an error. That way, the new cookie is never written so you keep having that old and bad cookie.

I usually wait with setting the Expires property until everything works, or use IE Cookies View (http://www.nirsoft.net/utils/iecookies.html) to clean out unwanted cookies every now and then.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning DW.MX 2004 Global Soccer terry s Dreamweaver (all versions) 6 October 13th, 2004 02:40 PM





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