Classic ASP BasicsFor 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
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?
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;
}
else
{
return true;
}
}
</script>
Call this function from the onsubmit handler for the form:
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.