This topic is locked
[SOLVED]

 Drop Down field

2/15/2010 8:30:26 AM
PHPRunner General questions
author

How would I setup this scenario in PHPRunner:
a Dropdown has a list of courses with amount of students allowed in that course. Once the class amount is reached it would disappear from the dropdown.
Now here is the sad part...I have done this before but unfortunately lost the code for this. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=13822&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />
Thanks for any help you can give me!!!
I did a search for my name and found this but it was for asprunner I think:

"You could have a table named "class_names" with fields called "class_id", "class_name" and "class_amount" which the "class_amount" field will hold the total amount of students allowed, in this case 16.

Then when a new record is added using a "look up dropdown box", subtract 1 off the total until 16 records have been added, once this reaches zero you could have it that the class name vanishes from the "drop down list" so its not available for selection.

Add Page

CODE

Function BeforeAdd(dict)
strSQLInsert ="UPDATE class_names SET class_amount=(class_amount-1) WHERE class_name ='"&dict("YourDropdownField")&"'"
dbConnection.Execute strSQLInsert
BeforeAdd = True

End Function
List Page

CODE

Function BeforeDelete(where)
str = "select Battle_Date from class_names where" & where

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
strSQLInsert ="UPDATE class_names SET class_amount=(class_amount+1) WHERE class_name ='"&rsTemp("YourDropdownField")&"'"

dbConnection.Execute strSQLInsert

BeforeDelete = True

End Function
Your drop down box would need something like this in the "Where" option.

CODE

"class_amount>=1"
This is only a sample.