I have is a set of HTML checkboxes and a Access database at the back end, when I retrieve the values of the checkboxes to process with Classic ASP I am running into a problem with undefined values. What I have discovered from research is that if a checkbox is not checked it will not passing anything as HTML checkboxes are either selected as 'on' or 'nothing'. However if it is checked then there is an on values passed and the yes/no field in the DB is checked. As you can imagine the DB needs a value and if an 'undefined' value is passed to a yes/no field, it results in a missing parameter error being sent. The compiled sql statement from a Response.Write command is: INSERT INTO tblHome (memberID, towncity, towndistance, towndirection, propertytype, flatfloor, flatblock, nobedrooms, nobathrooms, maxnoofpeople, carneeded, carexchange, smoking, swimpool, petcare, childrenallowed, plantcare, additionalinfo, picture)values ('2', 'London', '15', 'SE', 'Flat', '3', 'CC', '2', '2', '4', undefined, on, on, on, on, on, on, 'Hello', ''); Code (markup): *note the undefined The question: Is there any way to make the 'nothing/undefined' value that is sent from the unchecked checkbox into a 'off' value so that the asp doesn’t fail? Please bear in mind that I only realy understand JavaScript and am very new to asp. Hope that makes sense, any help would be greatly appreciated. Thanks Graham
Just declare the value to off, then check if it exists-if it exists in the post, then the value is true or "on" in your case Also - make sure to 'on' rather than on when inserting characters instead of int or booleans so you would do val1 = false if lcase(trim(request.form("val1"))) = "on" then val1 = true and in your sql just include (val1) instead of the posted variable Hope this helps...