Event Actions on an edit form

Event Actions on an edit form

Unread postby RGClay » Wed Mar 26, 2014 6:23 am

First, I'm a newbie to nuBuilder and a novice at PHP and mysql. That said, I was wondering how I could display the running length of a textarea on an edit form after each character is entered into the field (presumably using the keydown event or an event that makes sense.)? Any direction would be appreciated.
RGClay
 
Posts: 3
Joined: Wed Mar 26, 2014 6:13 am

Re: Event Actions on an edit form

Unread postby massiws » Wed Mar 26, 2014 9:23 am

RGClay,
no PHP or MySQL, but jQuery:
  • add an html object to your form to display remaining characters in textarea;
  • in Javascript tab insert this code:
    Code: Select all
    function nuLoadEdit() {
      $('#my_textarea_id').keyup(function () {
        var max = 10;
        var col = 'grey';
        var len = $(this).val().length;
        if (len >= max) {var col = 'red';}
        $('#html-obj')
          .text(max - len)
          .css('color', col);
      });
    }

Hope this helps,
Max
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Event Actions on an edit form

Unread postby RGClay » Wed Mar 26, 2014 2:11 pm

Thanks for the prompt reply. I'll be trying this first thing in the morning. I've found nuBuilder software to be exceptional! Many thanks to all involved!
RGClay
 
Posts: 3
Joined: Wed Mar 26, 2014 6:13 am

Re: Event Actions on an edit form

Unread postby RGClay » Thu Mar 27, 2014 12:37 pm

Thanks again, Max. The technique worked great.
RGClay
 
Posts: 3
Joined: Wed Mar 26, 2014 6:13 am

Re: Event Actions on an edit form

Unread postby admin » Thu Mar 27, 2014 1:05 pm

.
admin
Site Admin
 
Posts: 3406
Joined: Mon Jun 15, 2009 9:53 am
nuBuilder Version: 4.5


Return to Custom Code

Who is online

Users browsing this forum: No registered users and 3 guests