【问题标题】:How to use values from Input slider Range?如何使用输入滑块范围中的值?
【发布时间】:2020-12-08 16:32:10
【问题描述】:

我的 html 页面中有一个滑块,其值从 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 }}

我在同一页面 html 中有一个由“vues.py”中的函数生成的单词列表:

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

     return dict.keys()

所以在页面 html 中,我们有滑块和生成的单词没有值..

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

如果我们将光标更改为 0.4:它会显示在同一页面中:

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

我想做类似的事情: 一开始,它显示所有单词,然后如果我将光标移动到 0.4,它会将此值发送到 views.py 以仅获取值

【问题讨论】:

    标签: javascript html python-3.x web python-requests


    【解决方案1】:

    你是这个意思吗?

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-22
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      • 2018-09-22
      • 1970-01-01
      • 2021-01-02
      相关资源
      最近更新 更多