Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
How to hide and show a particular link on a sidebar menu based on checkbox value?

Is it possible to hide and show a link/icon on a sidebar menu based on checkbox value?

I have a checkbox that once enabled (value = on), the icon of that particular link on sidebar menu should be shown and once disabled will be hidden.

Hope someone could help me. Thanks!

file.html

{% elif field.type == 'checkbox' %} 
<div class="form-group"> 
<label>{{ field.prompt }}</label> 
<br> 
<input type="{{ field.type }}" class="form-control {{ field.name }}" name="{{ field.name }}"> 
</div>


$form_admin_config.validate({ 
ignore: 'input[type=hidden], .ignore', 
onkeyup: false, submitHandler: 
function(form) { 
$form_admin_config.find('input[type="checkbox"]').each( function () {
         var checkbox_this = $(this);

         if( checkbox_this.is(":checked") == true ) {
             checkbox_this.attr('value', 'on');    
         } else {
             checkbox_this.prop('checked',true);
             checkbox_this.attr('value', '');

             }
             })
             ajax_post_form($form_admin_config, 'Save Successful', function(){
             },
             function() {});
             }

        });

base.html

<li class="{% if request.mod == 'subscription_products' %}inactive{% endif %} main_menu" data-toggle="popover" data-content="Subscription Products">
<a href="{% url 'admin_app:subscription_products_index' %}" ><i class="fa fa-check-square-o"></i> <span class="nav-label"> Subscription Products </span></a></li>
{% endif %}

file.py

def admin_config_process(request):
    for key, val in request.POST.iteritems():
        if key != 'csrfmiddlewaretoken':
            admin_config = AdminConfig.getAdminConfigFromName(key)
            if admin_config is not None:
                admin_config.svalue = val
                admin_config.save()
            else:
                new_id = make_uuid()
                admin_config = AdminConfig.getAdminConfig(new_id)
                if radmin_config is not None:
                    new_id = make_uuid()
                AdminConfig(new_id, None, key, val).save()

    return jsonify({'status': 'ok'})
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try something like this:

$('#chk').click(function(){
  if( $(this).is(':checked') )
  {
    $('#link1').show();
  }
  else
  {
    $('#link1').hide();
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="checkbox" value="1" id="chk" />Check

<ul>
  <li id="link1">Link 1</li>
</ul>

You can get the checkbox value like:

$(this).val(); but this will give the same value doesn't matter whether the checkbox is checked or not. So you have to put the logic to get the value of checkbox only when it is checked.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!