根据给定的值过滤选择框,默认值为none

时间:2019-07-25 07:30:49

标签: javascript jquery

我在这个项目上工作,用户选择那里的“区域”,并且属于该区域或与该区域相关的数据将在下一个“选择框”(称为“城市”)中列出,我设法对区域和城市进行锻炼,在这个社区的帮助下,我非常感激。

我的问题是,如果我选择特定城市,则该城市的数据必须在barangay列表中。

我忘了一件事,如果该区域为空,则不得显示城市列表。

如果您需要fiddle

html

import numpy as np
import pandas as pd

data = pd.read_excel('TagValues.xlsx')
df = pd.DataFrame(data)
df['oiltag'] = df['oiltag'].astype(float)
df['runstattag'] = df['runstattag'].astype(float)
oil = df['oiltag']
runstat = df['runstattag']


def startup(oil,runstat):
    while oil.all() > 0:
        if oil > 0 and runstat == 0:       
            totaloil = sum(oil.all())
            print(totaloil)
        else:
            return None
    return 

print(startup(oil.all(), runstat.all()))

脚本

  var floats = [1.2,4.0,3.5,12];

  // Copy to bytes
  var result = new byte[floats.Length * sizeof(short)];
  Buffer.BlockCopy(floats, 0, result, 0, result.Length);

1 个答案:

答案 0 :(得分:2)

我使用了相同的隐藏逻辑,并使用id作为值来过滤选项:

$(document).ready(function() {
  $("#city").change(function() {
    var val = $(this).find(":selected").prop("id");
    $("#brgy option").hide();
    $("#brgy").val("");
    $("#brgy option[value='" + val + "']").show();
  });
  $("#region").change(function() {
    var val = $(this).val();
    $("#city option").hide();
    $("#city").val("");
    $("#city option[value='" + val + "']").show();
    $("#city").change();
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>SELECT YOUR THE REGION
  <select type="text" value="" id="region">
    <option value="">Please Select Your Region</option>
    <option value="CompostelaValey">CompostelaValey</option>
    <option value="DavaoOriental">DavaoOriental</option>
  </select>
</p><br><br>

<p>SELECT YOUR THE CITY
  <select type="text" name="city" id="city">
    <option value="">Please Select City/Municipality</option>

    <option value="DavaoOriental" id="Baganga">Baganga</option>
    <option value="CompostelaValey" id="Maragusan">Maragusan</option>
    <option value="DavaoOriental" id="MatiCity">MatiCity</option>
  </select>
</p><br><br>

<p>SELECT YOUR THE BARANGAY
  <select type="text" id="brgy">
    <option value="">Please Select Your Barangay</option>
    <option value="Baganga">Baculin</option>
    <option value="Baganga">Batawan</option>
    <option value="Baganga">Batiano</option>
    <option value="Baganga">Binondo</option>
    <option value="Baganga">Bobonao</option>
    <option value="Baganga">Campawan</option>
    <option value="Baganga">Central</option>
    <option value="Baganga">Dapnan</option>
    <option value="Baganga">Kinablangan</option>
    <option value="Baganga">Lambajon</option>
    <option value="Baganga">Lucod</option>
    <option value="Baganga">Mahan-ub</option>
    <option value="Baganga">Mikit</option>
    <option value="MatiCity">Central</option>
    <option value="MatiCity">Badas</option>
    <option value="MatiCity">Matiao</option>
    <option value="Maragusan">kalapagan</option>
  </select>
</p><br><br>