Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda