Ok here the code... Please help...

I will get crazy ;-)

<script>
$(document).ready(function(){
   var invalidation_comment = $('#test1_invalidation_comment').val();
   $('#test1_invalidation_comment__row').hide();
   if($('#test1_invalidation_comment').val())
       $('#test1_invalidation_comment__row').show();
   $('#test1_valid').change(function(){
        if($('#test1_valid').attr('checked')){
            $(this).attr('checked', 'checked');
            $('#test1_invalidation_comment').val('');
            $('#test1_invalidation_comment__row').hide();
            }
        else if($(this).attr('checked',false)){
            $(this).attr('checked',false);
            $('#test1_invalidation_comment').val(invalidation_comment);
            $('#test1_invalidation_comment__row').show();
            }
        else $('#test1_invalidation_comment__row').hide();
        });

});
</script>

On Fri, Jul 29, 2011 at 10:17 AM, Richard Vézina <
[email protected]> wrote:

> I took my base code there...
>
> Thanks anyway...
>
> Just rewrite my example :
>
> I enter a new record.
> Later somebody check the record and valid or not if this record can be
> extracted or not from the DB.
> Imagine this person find the record valid and this person check the valid
> checkbox
> 1 week later for an some reason, this record should not any more valid
> So the valid checkbox will be unchecked...
> But the checkbox was checked so I want my jQuery script to trigger and
> unwrap an other field that has the purpose to take the comment about
> unvalidation.
>
> That my basic need...
>
> Now to make it fully working, I have to also manage the possibility that
> the record get valid again, hide the commented unwraped field ans clear the
> input value (or text comment) that were leaved previously when it has been
> invalided the first time...
>
> My problem is that my code work to do that, but I have to submit to time to
> make the change applied at the DB level... What's bug me is that my entered
> invalidation comment text is actually cleared, but not submit...
>
> If you can find some time it will be greate and it could make a nice web2py
> slice I think...
>
> Richard
>
> On Thu, Jul 28, 2011 at 6:10 PM, Anthony <[email protected]> wrote:
>
>> I'm not sure I understand exactly what you need and don't have time to
>> check your app, but does this help at all:
>> http://web2py.com/book/default/chapter/10#Conditional-Fields-in-Forms?
>>
>> Anthony
>>
>> On Thursday, July 28, 2011 5:49:35 PM UTC-4, Richard wrote:
>>
>>> Hello,
>>>
>>> I know it's not a web2py question... But maybe there is a better jquery
>>> guy then me that can be of some help...
>>>
>>> I try to make a condition field (checkbox) that unhide an other field
>>> (text input) when the checkbox is uncheked... But I also want the unhided
>>> field to hide again in case the checkbox return in checked state.
>>>
>>> So...
>>>
>>> At the begining the valid field is empty when record will be revised it
>>> will be passed to valid so it will be checked.
>>> If for a reason in the future the validation has to be reverted I want to
>>> know why, so I want if checked box is unchecked to show a comment field
>>> about invalidation to be completed (I miss the conditionnal validator in my
>>> code).
>>>
>>> My implementation is working each 2 submit and I can't figure why it
>>> would work properly...
>>>
>>> Thanks you all.
>>>
>>> Richard
>>>
>>> PS.: See the little demo app attach.
>>>
>>>
>>>
>

Reply via email to