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 February 28th, 2004, 05:27 PM
Registered User
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Forms: Restrict user selection - How?

I have a client that wants me to create a form that will contain about 50 condo listings. He wants me to place a restriction on the form as to the number of Condo listings a user can select/request. Is that possible? If so, what will I need to do or use to make this stunt possible?

The items on each page would be different. The data is being passed between three pages. I would use ASP to past the data between the pages.

Lets say on page1 there are condos available (20) located in area A. On page2 there are condos available (15) located in area B. On page3 there are condos available (15) located in area C.

The user goes to page2 sees a condo that he/she would like information about. They select that condo.

The user has now selected one condo from page2.

If the user goes to page 1 or 3 and selects a condo from those pages when the user hits the Submit button, the program should not allow the page(s) to submit since the user has selected more than one condo. How can this be done?

Old February 28th, 2004, 08:01 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

If I understand you correctly, you could use a mix of Session variables (or cookies, or whatever you use to maintain state) in a combination with some JavaScript. Dump the number of selected condos in a JavaScript function that prevents the form from being submitted. Something like this:

  Dim NumOfCondos
  NumOfCondos = 2 ' Hard coded. Change with Session("Condo") or whatever

<script type="text/javascript" language="JavaScript">
  function SubmitMe()
    var localNumOfCondos;
    localNumOfCondos = <%=NumOfCondos%>; // assign ASP value
    if (localNumOfCondos > 1)
      alert('Too many condos selected');
      return false;
      return true;

Call this function from the onsubmit handler for the form:

<form name="bla" id="bla" onsubmit="return SubmitMe();">

The return in the onsubmit is important; if you omit it, the form will submit anyway.

Does this help?


Imar Spaanjaars
Everyone is unique, except for me.
Old February 29th, 2004, 03:37 AM
Friend of Wrox
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post

If you want to do this in VB, by the session, you could set a session variable for what the status is of that user as soon as they submit. If status is true, let them browse otherwise hide or disable the submit button.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict the user not to direct download rylemer Classic ASP Basics 8 December 15th, 2010 02:25 AM
How I can restrict desktop user to access some res anjanmaity General .NET 1 June 27th, 2008 01:40 PM
Login user & restrict access lucian Dreamweaver (all versions) 5 September 7th, 2003 12:21 PM

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