numero = 19181
interpreted = N
texte = >This is not really a Webcatalog question, but really an HTML question.>>How can I use checkboxes for editing boolean fields in a database?>>With Radio buttons I can use this:>[theField]=1]CHECKED[/ShowIf]>On>[theField]=0]CHECKED[/ShowIf]>Off>>But what about checkboxes? The value tag sent by the browser does not>change according to the CHECKED state of the checkbox?>>VALUE=[theField] [showif [theField]=1]CHECKED[/ShowIf]>>>Does not work...Here's one way to fix it:Put this just BEFORE the ending tag:This will set the theField value to zero when the checkbox is NOT checked.This technique works because the checkbox doesn't set a value for theField when it's unchecked, so this hidden field sets that value instead. Of course, if the checkbox is checked, the form will pass TWO values for theField ...But since all browsers currently send variables in the order they read them, and since WebCat sets variables in the order it receives them -- and since WebCat does NOT reset a value once it's been set -- this technique works now and will continue to work, at long as the hidden field appears AFTER the checkbox field in the form (and as long as browsers continue to pass variables in the order they appear in the form).One word of warning:HTML specs do *not* require browsers to send form variables in the order they appear in the form. Sure, it's common sense to do so -- and it's easier for browser authors to do it this way -- but it is not a requirement, so there may come a day when some browser will be programmed to pass form variables in a different order. If that even happens, and if the hidden field happens to get passed BEFORE the checkbox field, this technique won't work anymore.Sincerely,Ken Grome808-737-6499WebDNA Solutionsmailto:ken@webdna.nethttp://www.webdna.net
Associated Messages, from the most recent to the oldest:
>This is not really a Webcatalog question, but really an HTML question.>>How can I use checkboxes for editing boolean fields in a database?>>With Radio buttons I can use this:>[theField]=1]CHECKED[/ShowIf]>On>[theField]=0]CHECKED[/ShowIf]>Off>>But what about checkboxes? The value tag sent by the browser does not>change according to the CHECKED state of the checkbox?>>VALUE=[theField] [showif [theField]=1]CHECKED[/ShowIf]>>>Does not work...Here's one way to fix it:Put this just BEFORE the ending tag:This will set the theField value to zero when the checkbox is NOT checked.This technique works because the checkbox doesn't set a value for theField when it's unchecked, so this hidden field sets that value instead. Of course, if the checkbox is checked, the form will pass TWO values for theField ...But since all browsers currently send variables in the order they read them, and since WebCat sets variables in the order it receives them -- and since WebCat does NOT reset a value once it's been set -- this technique works now and will continue to work, at long as the hidden field appears AFTER the checkbox field in the form (and as long as browsers continue to pass variables in the order they appear in the form).One word of warning:HTML specs do *not* require browsers to send form variables in the order they appear in the form. Sure, it's common sense to do so -- and it's easier for browser authors to do it this way -- but it is not a requirement, so there may come a day when some browser will be programmed to pass form variables in a different order. If that even happens, and if the hidden field happens to get passed BEFORE the checkbox field, this technique won't work anymore.Sincerely,Ken Grome808-737-6499WebDNA Solutionsmailto:ken@webdna.nethttp://www.webdna.net
Kenneth Grome
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...