1

I try to display different content. But something i make false. If i check pid it must show only pid's, if i check pid and title it must show both. In my example i show both, but how i can change it with checkboxes? Thanks.

<form class="fedora" method="post">{% csrf_token %}
    <input type="checkbox"  name="pid" value="{{obj.pid}}"> pid
    <input type="checkbox" checked name="title" value="{{obj.title}}"> title
</form>

...

{% fedora_access %}
        <p><a href="{% url 'display' obj.pid %}"> 
        {%if  obj.pid %} {{ obj.pid }}|{% endif %}          
        {{ obj.pid }} | {{ obj.title }}  
        </a></p>  
{% end_fedora_access %}
  • You can do it using jquery alone. Wrap {{obj.title}} in a span, and on checkbox click, just show or hide the title – karthikr Jun 13 '13 at 15:01
1
<form class="fedora" method="post">{% csrf_token %}
    <input type="checkbox" id="show_pid"  name="pid" value="{{obj.pid}}"> pid
    <input type="checkbox" id="show_title" checked name="title" value="{{obj.title}}"> title
</form>

...

{% fedora_access %}
        <p><a href="{% url 'display' obj.pid %}">      
        <span class="show_pid">{{ obj.pid }}</span> | <span class="show_title">{{ obj.title }}</span>
        </a></p>  
{% end_fedora_access %}

Then in javascript:

$(function() {
    $('#show_pid').click(function() {
        if ($(this).is(':checked')) $('.show_pid').show();
        else                        $('.show_pid').hide();
    });
    $('#show_title').click(function() {
        if ($(this).is(':checked')) $('.show_title').show();
        else                        $('.show_title').hide();
    });
});

although, when neither are checked, you'll have | still showing. You can fake that with css. Give the spans a border-left: 1px solid black and a border-right: 1px solid black or something.

  • Thanks for the answer. I want to make it without javascript. Just using form – andy_bu Jun 14 '13 at 8:25
  • <form class="fedora" method="post">{% csrf_token %} {{ form }} <input class="suche_fedora" type="submit" value="SEARCH"/> <input type="checkbox" id="show_pid" name="pid" value="{{obj.pid}}"> pid <input type="checkbox" id="show_title" name="title" value="{{obj.title}}"> title </form> – andy_bu Jun 14 '13 at 8:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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