Yep, something like this (which is off the top of my head - syntax /detail may be incorrect!)

<select id="flavours">
  <option value="P">Pea</option>
  <option value="F">Fish</option>
  <option value="B">Bean</option>
</select>

<input type="text" style="display:none;" id="toppings" name="toppings">

Then, in jQuery

$('#flavours').change(function(){
  var lValue = $('#flavours').val();
  if (lValue === "P"){
    $('#toppings').show();
  }
  else {
    $('#toppings').hide();
  }
});

Hope that gets you started.

Tim.

On 10/01/11 18:18, hank23 wrote:
So in the widget attrs for the dropdown I should define an event and a
javascript function to call whenever the event (like onclick) fires?
So where's a good place to find the javascript code to actually
display the field? So do I make the field I want to display originally
a hidden field and then change the type in the javascript or do I mkae
the field originally a text input field, but somehow set it to be
invisible initially?

On Jan 10, 12:03 pm, Tim Sawyer<list.dja...@calidris.co.uk>  wrote:
On 10/01/11 17:44, hank23 wrote:

First is it possible to conditionally hide a form field on a screen
until an item from a dropdown box has been selected? If so how can
that be done?

Yes, but you'll have to use jQuery or similar and script it with
JavaScript, so that when the droplist changes you fire some javascript
to change the fields that are displayed.

Second I have some message fields defined in a form which are
basically for information purposes. When I drop them on my screen they
are displayed in text boxes, which I do not like. Is it possible to
instead display them within label tags or somehow get rid of the boxes
surrounding them while also making them non-enterable(right now
they're being displayed in text boxes they can be typed over or
otherwise altered)? If so how? If not then should I just be displaying
them outside of the form portion of the screen then instead of within
the form?

Specify each field individually and just output text for the ones you
want to be readonly.  
See:http://docs.djangoproject.com/en/dev/topics/forms/#customizing-the-fo...

Tim


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to