I was wondering if somebody could help me with a bit of code, we are currently using mrbs and I have a bit of an issue with it at the moment when staff book a room they are not selecting there department and just leave it as default, the default entry is A in a list array which I have set to please select your department.
what I want to do is to force the them to select any entry apart from default by throwing up an error if not selected I have managed to get as far as getting the error on screen but I unable to link it with the entry type.
As far as I can see your approach is fundamentally wrong. You want to output the same HTML each time, whatever you are doing. Then on your postback, validate the form (this would include checks on the combobox select, obviously).
If the validation(s) fail then you need to mark them somehow - for example have an red asterisk alongside those which are wrong, and reseed the HTML Form controls with the data, so they don't have to type it in again.
Don't assume this works however ; your server side PHP should still cope with bad values - even if it just throws an error if it gets a value that the validation says it shouldn't.
a quick thinkup php side goes somthing like this! presuming your passing information with the POST method?
$deptcheck = $_POST["<<INSERT FIELD NAME HERE>>"];
if $deptcheck == "Please Select your Department"
<<insert error / handle code here>>
Those 3 lines (as you have "Please Select your Department" as default) checks the information submitted to the <<INSERT FIELD NAME HERE>> field, to see if it matches, and if it does then it would mean that the user has not selected another option.
Thanks for your replies guys I appreciate it, So far I have managed to force the error please select your department by using a jquery script, but unfortunately I can only get it to work with a seperate save button.
I some how have to figure out how to link my script with the original save button.
just a thought to add in. if this is part of a larger form, make sure your php feedback page carries valid form values over to the feedback page. if i fill in ten boxes then miss a drop down, i'd like the ten boxes to stay filled in or to be held in hidden inputs so i can just focus on correcting the dropdown. i guess you could rely on people clicking the back button but i've had that reset the form before (not sure if blanking the form was a browser thing or a "feature" of the page that had been coded in)