Jump to content

Disable Checkboxes At Specific Times


jbsmith
 Share

Recommended Posts

Hello,I have inherited some .ASP pages and have been given some tasks with them. First let me say that I haven't been formally trained in web development, but can generally read code and understand what it is doing. But making changes to it is a different story.one of these asp pages is a registration page for classes. It has multiple checkboxes all with different names. Looks like the names are different because the submit button writes multiple items to a database based on the checkbox name.I have been asked to 'turn off registration' a day before the class starts. So my thought was to throw up an alert message when someone trys to register for a 'closed' class and then unclick the checkbox for them. This I have done successfully using the following and calling it from the

onclick = "regclosed(this)"

function regclosed(which) {alert("Registration for this class has closed." + '\n' + '\n' + "Select Another Class");which.checked = false;}

So right now I would have to edit this registration page each time an item 'closes' to add the onclick event.Is there a way I can automate this? Meaning can I set a time for the onclick - it only fires after x date?

Edited by jbsmith
Link to comment
Share on other sites

You'll want to do this in ASP instead of Javascript, if it's in Javascript it's going to use the clock on the user's computer instead of the clock on the server. If you have the date the class starts in the database or wherever, it's easy enough to figure out if the date is within 24 hours of the current time.

Edited by justsomeguy
Link to comment
Share on other sites

You'll want to do this in ASP instead of Javascript, if it's in Javascript it's going to use the clock on the user's computer instead of the clock on the server. If you have the date the class starts in the database or wherever, it's easy enough to figure out if the date is within 24 hours of the current time.
Ok I think I get what your saying...just turn it into some type of validation check. If datediff ("h", startdate, now) <= 24 then "sorry registration closed"Am I understanding you correctly?
Link to comment
Share on other sites

Ok - being that this (web design) is not my forte - can you point me to an example of a server side validation? I am a bit confused as to how I can have the server validate this and then if it finds an error to not let anything post to the db and throw a message to the user.I suppose I probably need to move this - or start a new thread - in the asp forum.

Link to comment
Share on other sites

well it is quite lengthy to put it all here so I will try to just put the important parts that relate to the subject.the registration page...

<form method="Post" action="TEST.asp" name="registration" ><input type="checkbox" id="aspire" name="Aspire" value="March12_13_19_20_26_27" /> </form>

The Test.asp page that processes the checkboxes from the registration page (This shows the validation to check if its closed) right now it just goes back one page. I just threw this on here yesterday after a few of your posts. I don't really like how this works/looks. I don't know how to modify the registration page after this has been processed? After this code there is a bunch of code that is used to insert into the database and ultimately is a result page (shows the user they registered).:

<% 'is registration closedif aspire<>"" then	dim date1, aspDate, strDateDiff	date1 = Now()	wpeDate = "22/07/2009"	strDateDiff = DateDiff("H",Date1, aspDate)	If strDateDiff <= 24 Then%>		<script type="text/javascript">		alert("Registration is closed for ASPIRE")		history.go(-1)		</script>		<%		response.end	end ifend if%>

Edited by jbsmith
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...