Thanks a trillion! I had started looking at the jQuery specifications and had immediately zeroed in on .attr but, because of my unfamiliarity with Javascript in general and jQuery in particular, I didn't see the particular issue just yet.
Your help is extremely appreciated. It's very difficult to learn from a book when the book contains errors, and I have spent the entire summer running around trying to get these book errors corrected when I find them. On Sat, Sep 7, 2013 at 4:33 AM, Alex <[email protected]> wrote: > write > if(jQuery('#taxpayer_married').is(':checked')) > instead of > if(jQuery('#taxpayer_married').attr('checked')) > > attr returns the value as it is initially defined in html. With 'is' you > are querying the current state. > > Alex > > Am Samstag, 7. September 2013 05:34:33 UTC+2 schrieb REM: > >> >> I am trying out the 11.2.1 book example on p.504, and it just doesn't >> function at all. I've tried it with Firefox and Chromium and the behavior >> is the same. Instead of the spouse name field appearing when the box is >> checked, nothing happens. I've checked the book code against the web book >> code against my code and they all appear to be the same. >> >> Please help find my error! >> >> Here's a cut and paste from the relevant book section: >> >> *As an example, create an input form that asks for a taxpayer's name and >> for the name of the taxpayer's spouse, but only if he/she is married. >> Create a test application with the following model: >> * >> >> db = DAL('sqlite://db.db') >> db.define_table('taxpayer', >> Field('name'), >> Field('married', 'boolean'), >> Field('spouse_name')) >> >> >> *the following "default.py" controller:* >> >> def index(): >> form = SQLFORM(db.taxpayer) >> if form.process().accepted: >> response.flash = 'record inserted' >> return dict(form=form) >> >> *and the following "default/index.html" view: >> * >> {{extend 'layout.html'}} >> {{=form}} >> <script> >> jQuery(document).ready(function(){ >> jQuery('#taxpayer_spouse_name__row').hide(); >> jQuery('#taxpayer_married').change(function(){ >> if(jQuery('#taxpayer_married').attr('checked')) >> jQuery('#taxpayer_spouse_name__row').show(); >> else jQuery('#taxpayer_spouse_name__row').hide();}); >> }); >> </script> >> >> *The script in the view has the effect of hiding the row containing the >> spouse's name: >> * >> >> Unfortunately, in my tests, there's no effect. It certainly *looks* from >> the code as though the row should appear and disappear based on the >> checkbox, but it doesn't seem to be happening for me. Why doesn't it work? >> >> Does it work for you? >> >> Thanks..... >> >> >> -- > > --- > You received this message because you are subscribed to a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/UWUmUOP8ljE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

