[pmwiki-users] input fox

noskule noskule at gmx.net
Tue Feb 26 14:24:44 CST 2008


Hans schrieb:
> Tuesday, February 26, 2008, 2:17:10 PM, noskule wrote:
>
>   
>> I try to build a form with checkboxes. If there are switches on the 
>> value should be 0 else 1.
>> The code below let switch the boxes on but not off anymore. Does anyone
>> see the problem?
>>     
>
> I can see several difficulties:
>
> 1. If the checkbox is not checked, no value of any kind is sent to the
> server. By default, checkboxes send 'on'. If you need  a checkbox
> which is checked when the page loads, use checked=1. The value does
> not determine if the box is checked or not.
>
> So if you want something posted (to change the PTV value) you would
> need to use conditional markup to display conditionally
> either a checkbox with value A, or one with value B
>
> 2.  you can with the latest fox.php use option ptvclear to allow
>  clearing a PTV when there is no input from a form field
> associated with a PTV.
> That would allow toggling the PTV between 1 and empty.
> Maybe you can work with that.
>
>   
yes ptvclear does the trick, thanks

> Example:
> Value toggles from 1 to empty, checkbox toggles from unchecked to
> checked.
>
> (:if equal {$:Test} 1:)
> (:input checkbox Test 1 checked=1:)
> (:else:)
> (:input checkbox Test 1 :)
> (:if:)
>
> 3. If you need value 0, perhsp it is better to use radiobuttons, one
> for value 1 and one for value '0'.
>
> 4. With Fox you can use name=$:Var as you did, but name=Var or simply
> (:input checkbox Var Value:) will do as well, as Fox checks for PTVs
> with the name of input fields, if you use ptvtarget= option.
> ptvfields= will restrict that check to specified PTV names.
>
>
>   ~Hans
>
>   




More information about the pmwiki-users mailing list