Welcome Guest, Not a member yet? Register   Sign In
How to Count the number of receipients and insert in the database
#9

Like I said before: create a hidden field and let jQuery assign a value to it before the AJAX call is done.

Next to the span element, create a hidden input:
Code:
<input type="hidden" name="message_count" id="message_count" value="0" />

Also, adjust your jQuery script that responds to keyup in the message textarea:
Code:
$('#body').keyup(function(){
    var chars = this.value.length,
        messages = Math.ceil(chars / 160),
        remaining = messages * 160 - (chars % (messages * 160) || messages * 160);

    $remaining.text(remaining + ' characters remaining');
    $messages.text(messages + ' page(s)');
       $('#message_count').val(messages);   //this line is new!
});

Now, remember that the POST value for the controller is message_count, not messages.
Reply


Messages In This Thread
RE: How to Count the number of receipients and insert in the database - by Wouter60 - 02-20-2018, 12:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB