2

I have a Range Slider in my template. I want to call a function in my view on Range Slider value change.

index.html
<input id="slider1" type="range" value="3" min="1" max="20" step="1" />

I am using a button and text also I took help from this

Python 2.7.10 Django 1.9

Community
  • 1
  • 1
utkarsh
  • 333
  • 1
  • 3
  • 11
  • I want value of slider also so as I can change my calculation in function which is defined in view – utkarsh Aug 02 '16 at 12:00

1 Answers1

1

Assume you have call_view(request) to call...

<input type="range" ... onchange="callFun(this.value)">

Note: I used fetch

function callFun(value) {
    fetch('call_your_url/?value='+ value).then(function(response) {
        console.log(response.status);
    }
}

In your view function...

def call_view(request):
    request.GET.get('value')
    return HttpResponse("success")
Raja Simon
  • 10,126
  • 5
  • 43
  • 74