also, just as a head's up... even when you store numbers as the "value" attribute on an <option/> tag, they are interpreted as strings in javascript. so, from your example above, you might also consider switching your condition to:
// Compare as string instead if ($("#id_status").val() === '6'){ $('div.textfield1').show(); } when you compare the two as strings using the strict equality operator (===), your results will likely be far more predictable. hope that helps. On Nov 18, 2:03 pm, mtuller <mitul...@gmail.com> wrote: > Thanks. > > On Nov 18, 1:50 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > > > You're missing a $ on this line: > > > ('#id_status').change(function() { > > > Change to: > > > $('#id_status').change(function() { > > > unsolicited word of advice... run firebug :) > > > On Wed, Nov 18, 2009 at 11:44 AM, mtuller <mitul...@gmail.com> wrote: > > > I am trying to have a div show and hide based on the value of a select > > > list. I have looked at a number of examples, but can't seem to get it > > > to work. Would appreciate someone taking a look at what I have and > > > giving me any advice. > > > > <script> > > > $(document).ready(function() { > > > $('div.textfield1').hide(); > > > > ('#id_status').change(function() { > > > > if ($("#id_status").val() == 6){ > > > $('div.textfield1').show(); > > > } > > > else{ > > > $('div.textfield1').hide(); > > > } > > > }); > > > }); > > > </script> > > > > <p><label for="id_status">Status:</label> > > > <select name="status" id="id_status"> > > > <option value="1">New</option> > > > <option value="2">In Review</option> > > > <option value="3">Working On</option> > > > <option value="4">Elevated</option> > > > <option value="5">Approved</option> > > > <option value="6">Deferred</option> > > > <option value="7">Denied</option> > > > <option value="8">Duplicate</option> > > > <option value="9">Completed</option> > > > <option value="10">Needs more information</option> > > > </select></p> > > > > <div class="textfield1"> > > > <label>test > > > <input type="text" name="text" id="text" /> > > > </label> > > > </div> > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success.