1

enter image description hereI can barely cut and paste JS stuff and have not seen an example of this anywhere. I have added a vertical tab to the node admin page and I want to show either "Limited" when the value of a field in the tab is not zero or "Not limited" if it is.

I see lots of examples of using check boxes, but this is a numeric field.

4
  • Sorry but your Q is unclear to me. Show limited and unlimited where? value of which field? Maybe a screenshot with some arrows pointing at stuff would help.
    – No Sssweat
    Commented Sep 7, 2016 at 23:26
  • In the tab itself, much like the publishing options are shown. Or where it shows "Display" or "Don't display post information." The field is "content_limit_count" which can be zero for unlimited or some number for a limit. The number is used in the code, but on the node admin page all I want to show is whether or not there is a limit.
    – NancyDru
    Commented Sep 8, 2016 at 0:02
  • Ugh... maybe it's just me, but I'm still not get in it.
    – No Sssweat
    Commented Sep 8, 2016 at 0:59
  • Okay, I added a picture.
    – NancyDru
    Commented Sep 8, 2016 at 2:38

1 Answer 1

0

Sorry for the late response, your question escaped my mind.

(function ($) {
   (function Forever(){ // we create a function called Forever
     var grabval = $('#edit-title').val();
     $('.vertical-tab-button').each(function(){ 
       if ($(this).children().children('strong').text() == 'Content Limit'){
         if (grabval == 0 && $(this).children().children('span') == null){
           $(this).children().children('strong').after('<span class="summary">Not Limited</span>');        
         }
         else if (grabval == 0 && $(this).children().children('span') != null){
           $(this).children().children('span').html('Not Limited');        
         }
         else if (grabval != 0 && $(this).children().children('span') == null){
           $(this).children().children('strong').after('<span class="summary">Limited</span>');   
         }
         else if (grabval != 0 && $(this).children().children('span') != null){
           $(this).children().children('span').html('Limited');        
         }  
       }       
     });   
   setTimeout(Forever, 1);
   })();
})(jQuery)

I used the node title for mine, so if you change the title to 0 or 1 or 2 ..etc, it will change.

So all you have to do is change the var grabtext = $('#edit-title').val(); more specifically the #edit-title part, and put the ID or Class name of your Maximum per time period box.

1
  • Suggestion: remove the very 1st line of your answer (no need for "sorry" ... after all: better late then never, no?). Commented Dec 17, 2016 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.