简体   繁体   English

如何使用输入 slider 范围中的值?

[英]How to use values from Input slider Range?

I have in my html page a slider with value from 0 to 0.5:我的 html 页面中有一个 slider 的值从 0 到 0.5:

 <form method="POST" action="{% url 'words_url' id %}"   class="words">
   {% csrf_token %}
   <fieldset>
   <label for="rangeVal">Popularity threshold</label>
   <input type ="range" max="0.5" min="0"
   oninput="document.getElementById('rangeValLabel').innerHTML = this.value;"
   step="0.01" name="rangeVal" id="rangeVal" value="0.7">
   </input>
   <em id="rangeValLabel" style="font-style: normal;"></em>
   </fieldset>
   
   {{ form|crispy }}

and i have in the same page html a list of words generated by a function in "vues.py":我在同一页面 html 有一个由“vues.py”中的 function 生成的单词列表:

 def funct_words(request, id) :
     dict={"new":0.3,"blue":0.6,"Green":0.04}

     return dict.keys()

so in the page html, we have the slider and the generated words without value..所以在页面 html 中,我们有 slider 和生成的单词没有值..

  the slider : ----------------------------------
  generated words: new,blue,Green

if we change cursor to 0.4: it display in tha same page just:如果我们将 cursor 更改为 0.4:它仅显示在同一页面中:

   the slider : ---------------------------------- 0.4
  generated words: new

i want to do something like: at the beginning, it display all words, then if i move the cursor to 0.4, it send this value to views.py to get only words which have value < 0.4, then it display the results in the same page html (I want only to get the value from the slider after the mouse is released, not during the mousedown and drag, then send the value to the vues.py then get the corresponding result.. help please?我想做类似的事情:一开始,它显示所有单词,然后如果我将 cursor 移动到 0.4,它会将这个值发送到 views.py 以仅获取值 < 0.4 的单词,然后将结果显示在同一页面 html (我只想在鼠标释放后从 slider 获取值,而不是在鼠标按下和拖动期间,然后将值发送到 vues.py 然后得到相应的结果..请帮忙?

Do you mean this?你是这个意思吗?

 function updateTextInput(value) { console.log(value) // here you could do the logic and send to your server. }
 <input value="0" type="range" oninput="updateTextInput(this.value);" onchange="updateTextInput(this.value);" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM