Hi,
I tried to display a conditional field using jQuery with "no_table_"
as the table name since i am using an SQLFORM.factory. The jQuery code
was copied from the latest web2py manual. I've been reviewing it for
hours and test ran it, however i was not successful. I don't know if
this is a web2py or jQuery issue, is there something i missed here?
Here's the code:
--------------------------------------------------------------
Controller:
form = SQLFORM.factory(
Field('fromyr', label='Enrolled',default=auth.user.fromyr),
Field('toyr', label='.................. - To
Year',default=auth.user.toyr),
Field('usc_educ', 'usc_educ',default=auth.user.usc_educ,label='USC
Education'),
Field('educ_updt','boolean', label='Update Education?'),
Field('usceduc_updt','usceduc_updt',requires=IS_IN_DB
(db,'degreecurric.curcode','%(curcode)s'),label='USC Educ.
update'))
form[0]-1][1].append(INPUT
(_type='button',_value='Cancel',_onclick="window.location='%s';"%URL
(r=request,f='index')))
#form[0][-5][1].append(H3(_type='text',_value='(if any)'))
---------------------------------------------------
View:
{{extend 'layout2.html'}}
<h2>Education</h2>
<p><b>Name:   {{=auth.user.first_name}}  
{{=auth.user.mid_name}}   {{=auth.user.last_name}}</b></p>
<p><b>{{=usc_ed}}</b></p>
<p>    Fill all form fields.</p>
{{=form}}
<script>
jQuery(document).ready(function(){
jQuery('#no_table_usceduc_updt_row').hide();
jQuery('#no_table_educ_updt').change(function(){
if(jQuery('#no_table_educ_updt').attr('checked'))
jQuery('#no_table_usceduc_updt_row').show();
else jQuery('#no_table_usceduc_updt_row').hide();});
});
</script>
<p>Copyright © 2009 - Powered by <a href="http://
www.web2py.com">web2py</a></p>
</body>
</html>
---------------------------------
Thanks in advance for your help.
ed
On Oct 16, 4:56 pm, ed <[email protected]> wrote:
> Hi Boris,
> Thank you, will try using "no_table_". I am still grappling withjQuery. I
> have a 2 select options as condition to implement. Thanks
> again.
> Ed
>
> On Oct 15, 7:12 pm, Boris Manojlovic <[email protected]>
> wrote:
>
> > no_table_fieldname
>
> > so "no_table" is what you need
>
> > On Thu, Oct 15, 2009 at 8:55 AM, ed <[email protected]> wrote:
>
> > > Hi,
> > > In the example onconditionalfieldsgiven in Web2py manual the
> > > convention is, every INPUT field have a name equal to
> > > "tablename_fieldname" and it contained in a called
> > > "tablename_fieldname_row". However, SQLFORM.factory doesn't have a
> > > table, it is allfields. Can someone tell me, what name is the INPUT
> > > field equal to? I need this for thejQuerycode to test condition on a
> > > field defined in SQLFORM.factory. Thank you in advance.
>
> > --
> > "Only two things are infinite, the universe and human stupidity, and
> > I'm not sure about the former."-Albert Einstein
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---