[SOLVED] Drop Down field |
2/15/2010 8:30:26 AM |
PHPRunner General questions | |
author
How would I setup this scenario in PHPRunner: "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. |
|