I am using a jquery character counter and integrating it with my form helpers in Codeigniter.I’ve got everything working as it should, however when I’m using this script, parentheses are not showing up. I typed them in and used the ascii codes, and they only show up when I take off the script.
Any idea what this maybe?
thanks in advance.
javascript:
<script>
function updateCountdown_mylife() {
var remaining = 1340 - jQuery('.message_mylife').val().length;
jQuery('#mylife').text(remaining + ' characters remaining.');
}
jQuery(document).ready(function($) {
updateCountdown_mylife();
$('.message_mylife').change(updateCountdown_mylife);
$('.message_mylife').keyup(updateCountdown_mylife);
});
function updateCountdown_occupation() {
var remaining = 200 - jQuery('.message_occupation').val().length;
jQuery('#occupation').text(remaining + ' characters remaining.');
}
jQuery(document).ready(function($) {
updateCountdown_occupation();
$('.message_occupation').change(updateCountdown_occupation);
$('.message_occupation').keyup(updateCountdown_occupation);
});
</script>
html:
My Life <br /><span class="title_sub_text">Tell us a about yourself</span> <span class="edit_sub_text" id="mylife">(1350 character limit)</span>
textarea:
<div class="edit_text_area">
<?php
if(empty($user['mylife']))
{
$data = array('name' => 'mylife', 'class' => 'message_mylife');
echo form_textarea($data);
}
else
{
$data = array('name' => 'mylife', 'class' => 'message_mylife');
echo form_textarea($data, $user['mylife']);
}
?>
</div>
thans in advance
If I understand what you are saying then the parenthesis are not showing up because you are overwriting the span text and not putting the parenthesis there while over-writing. For example, shouldn’t the relevant code in
updateCountdown_mylifebe modified asNote the parenthesis included within. Also to display
(1350 character limit)at start-up, just comment outupdateCountdown_mylifecall in start-up code i.e.I have modified JS fiddle with these changes – check it out here: http://jsfiddle.net/GjRYL/1/ – hopefully, this is what you are after.