I have a form where I select a message from a dropdown field and then show the message in a textarea box beside it. I use jquery to pull the value of the dropbox and put it as the value of the textarea, like so:
$("#id_maturity_letter").change(function() {
var id = $(this).val();
$("#message_text").val($("option:selected", this).text());
$.getJSON('', {id:id}, function(json) {
});
});
My only issue is that my message returns like so:
def __unicode__(self):
return "%s" % self.body[0:20]
Reason being so that the message in the dropdown doesn’t span the entire page and then some. Now is it possible to show a truncated message in the dropdown but a full message in the “preview” textbox? Using jquery/django of course.
I am having trouble trying to figure this one out.
Steve
You can use two dropdown lists: one with truncated texts and one (hidden) with full text
or build a js array with id -> full description