I have a textarea with select list to put content into my textarea. I know how to count the dynamic value from the select list, but if I write some text after putting value on the textarea, the counter doesn't work. Any idea ?
Html :
<div id="selectmodelediv">
<select>
<option value=""></option>
<option value="1111">test1</option>
<option value="222">test2</option>
</select>
<br/>
<textarea id="targetText" name="targetText" class="champ_tel_txtarea" rows="6" cols="50"></textarea>
<div id="compteur" class="compteur"></div>
</div>
Jquery :
$('select').change(function () {
$('#targetText').val($('#selectmodelediv select').val()) //
$('#compteur').text('255 characters left');
var max = 255;
var len = $(this).val().length;
if (len >= max) {
$('#compteur').text(' you have reached the limit');
} else {
var ch = max - len;
$('#compteur').text(ch + ' characters left');
}
});