Javascript 如何获取下拉值变化时的下拉数据?

Javascript 如何获取下拉值变化时的下拉数据?,javascript,jquery,amp-html,Javascript,Jquery,Amp Html,您能告诉我如何获取下拉值变化的下拉数据吗? 我正在使用此链接创建链接下拉列表 这是我的密码 <!doctype html> <html ⚡> <head> <title>Linked Dropdowns</title> <link rel="canonical" href="https://ampbyexample.com/advanced/linked_dropdowns/"> <meta

您能告诉我如何获取下拉值变化的下拉数据吗? 我正在使用此链接创建链接下拉列表

这是我的密码

<!doctype html>
<html ⚡>
<head>
    <title>Linked Dropdowns</title>
    <link rel="canonical" href="https://ampbyexample.com/advanced/linked_dropdowns/">

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <!-- #### Setup -->
    <!-- First we include `amp-bind` to track the page state and update the ``<amp-list>` data source. -->
    <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
    <!-- Next we include `amp-list` to request and display the dropdowns and their options. -->
    <script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
    <!-- Finally, we include `amp-mustache` to render the mustache templates inside the `<amp-list>`s. -->
    <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>

    <style amp-boilerplate>body {
        -webkit-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        -moz-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        -ms-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        animation: -amp-start 8s steps(1, end) 0s 1 normal both
    }

    @-webkit-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-moz-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-ms-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-o-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }</style>
    <noscript>
        <style amp-boilerplate>body {
            -webkit-animation: none;
            -moz-animation: none;
            -ms-animation: none;
            animation: none
        }</style>
    </noscript>

    <style amp-custom>
        label {
            font-weight: bold;
        }

        [role="listitem"] {
            display: flex;
        }

        [role="listitem"] > * {
            flex: 1 0 0;
        }

        amp-list {
            margin: 10px 20px;
            min-width: 240px;
        }

    </style>
</head>
<body>

<div>
    <amp-list width="auto" single-item items="." height="25" layout="fixed-height"
              src="https://biz.com/getlist">
        <template type="amp-mustache">
            <label for="country">Country:</label>
            <select id="country"
                    on="
                  change:
                    AMP.setState({
                      cities: dropdown.data.filter(x => x.text_val == event.value)[0]
                    })">
                 <option value="">Choose country</option>

                {{#data}}
                <option value="{{text_val}}">{{text_val}}</option>
                {{/data}}
            </select>
        </template>
    </amp-list>


    <amp-list width="auto"
              height="25"
              layout="fixed-height"
              single-item items="."
              [src]="cities || 'https://biz.com/bankifddsc/getlist?seo_bank='+cities.seo_val"
              src="https://biz.com/bankifddsc/getlist?seo_bank='+cities.seo_val">
        <template type="amp-mustache">
            <label for="city">City:</label>
            <select [disabled]="!cities"
                    disabled
                    id="city">
                {{#data}}
                <option value="{{seo_val}}">{{text_val}}</option>
                {{/data}}
            </select>
        </template>
    </amp-list>


</div>

</body>
</html>
当我选择第一个选项(ZILA SAHAKRI BANK LIMITED GHAZIABAD)时,我希望在这个url的第二个下拉列表中加载数据

url中有数据

这是我的密码

<!doctype html>
<html ⚡>
<head>
    <title>Linked Dropdowns</title>
    <link rel="canonical" href="https://ampbyexample.com/advanced/linked_dropdowns/">

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <!-- #### Setup -->
    <!-- First we include `amp-bind` to track the page state and update the ``<amp-list>` data source. -->
    <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
    <!-- Next we include `amp-list` to request and display the dropdowns and their options. -->
    <script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
    <!-- Finally, we include `amp-mustache` to render the mustache templates inside the `<amp-list>`s. -->
    <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>

    <style amp-boilerplate>body {
        -webkit-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        -moz-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        -ms-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        animation: -amp-start 8s steps(1, end) 0s 1 normal both
    }

    @-webkit-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-moz-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-ms-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-o-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }</style>
    <noscript>
        <style amp-boilerplate>body {
            -webkit-animation: none;
            -moz-animation: none;
            -ms-animation: none;
            animation: none
        }</style>
    </noscript>

    <style amp-custom>
        label {
            font-weight: bold;
        }

        [role="listitem"] {
            display: flex;
        }

        [role="listitem"] > * {
            flex: 1 0 0;
        }

        amp-list {
            margin: 10px 20px;
            min-width: 240px;
        }

    </style>
</head>
<body>

<div>
    <amp-list width="auto" single-item items="." height="25" layout="fixed-height"
              src="https://biz.com/getlist">
        <template type="amp-mustache">
            <label for="country">Country:</label>
            <select id="country"
                    on="
                  change:
                    AMP.setState({
                      cities: dropdown.data.filter(x => x.text_val == event.value)[0]
                    })">
                 <option value="">Choose country</option>

                {{#data}}
                <option value="{{text_val}}">{{text_val}}</option>
                {{/data}}
            </select>
        </template>
    </amp-list>


    <amp-list width="auto"
              height="25"
              layout="fixed-height"
              single-item items="."
              [src]="cities || 'https://biz.com/bankifddsc/getlist?seo_bank='+cities.seo_val"
              src="https://biz.com/bankifddsc/getlist?seo_bank='+cities.seo_val">
        <template type="amp-mustache">
            <label for="city">City:</label>
            <select [disabled]="!cities"
                    disabled
                    id="city">
                {{#data}}
                <option value="{{seo_val}}">{{text_val}}</option>
                {{/data}}
            </select>
        </template>
    </amp-list>


</div>

</body>
</html>

链接下拉列表
身体{
-webkit动画:-amp开始8s步骤(1,结束)0s 1正常两个步骤;
-moz动画:-amp开始8s步骤(1,结束)0s 1正常两个步骤;
-ms动画:-amp开始8s步骤(1,结束)0s 1正常两个步骤;
动画:-amp开始8s步骤(1,结束)0s 1正常两者
}
@-webkit关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@-moz关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@-ms关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@-o关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
身体{
-webkit动画:无;
-moz动画:无;
-ms动画:无;
动画:无
}
标签{
字体大小:粗体;
}
[role=“listitem”]{
显示器:flex;
}
[role=“listitem”]>*{
弹性:100;
}
安培表{
利润率:10px 20px;
最小宽度:240px;
}
国家:
选择国家
{{{#数据}
{{text_val}}
{{/data}
城市:
{{{#数据}
{{text_val}}
{{/data}
试试这个:

<!doctype html>
<html ⚡>
<head>
    <title>Linked Dropdowns</title>
    <link rel="canonical" href="https://ampbyexample.com/advanced/linked_dropdowns/">

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <!-- #### Setup -->
    <!-- First we include `amp-bind` to track the page state and update the ``<amp-list>` data source. -->
    <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
    <!-- Next we include `amp-list` to request and display the dropdowns and their options. -->
    <script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
    <!-- Finally, we include `amp-mustache` to render the mustache templates inside the `<amp-list>`s. -->
    <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>

    <style amp-boilerplate>body {
        -webkit-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        -moz-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        -ms-animation: -amp-start 8s steps(1, end) 0s 1 normal both;
        animation: -amp-start 8s steps(1, end) 0s 1 normal both
    }

    @-webkit-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-moz-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-ms-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @-o-keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }

    @keyframes -amp-start {
        from {
            visibility: hidden
        }
        to {
            visibility: visible
        }
    }</style>
    <noscript>
        <style amp-boilerplate>body {
            -webkit-animation: none;
            -moz-animation: none;
            -ms-animation: none;
            animation: none
        }</style>
    </noscript>

    <style amp-custom>
        label {
            font-weight: bold;
        }

        [role="listitem"] {
            display: flex;
        }

        [role="listitem"] > * {
            flex: 1 0 0;
        }

        amp-list {
            margin: 10px 20px;
            min-width: 240px;
        }

    </style>
</head>
<body>

<div>
    <amp-list width="auto" single-item items="." height="25" layout="fixed-height"
              src="https://example.com/getlist">
        <template type="amp-mustache">
            <label for="country">Country:</label>
            <select id="country"
                    on="change:AMP.setState({cities: event.value})">
                 <option value="">Choose country</option>

                {{#data}}
                <option value="{{seo_val}}">{{text_val}}</option>
                {{/data}}
            </select>
        </template>
    </amp-list>
    <amp-list width="auto"
              height="25"
              layout="fixed-height"
              single-item items="."
              [src]="'https://example.com/getlist?seo_bank='+cities"
              src="https://example.com/getlist?seo_bank=1">
        <template type="amp-mustache">
            <label for="city">City:</label>
            <select [disabled]="!cities"
                    disabled
                    id="city">
                {{#data}}
                <option value="{{seo_val}}">{{text_val}}</option>
                {{/data}}
            </select>
        </template>
    </amp-list>

   </div>

</body>
</html>

链接下拉列表
身体{
-webkit动画:-amp开始8s步骤(1,结束)0s 1正常两个步骤;
-moz动画:-amp开始8s步骤(1,结束)0s 1正常两个步骤;
-ms动画:-amp开始8s步骤(1,结束)0s 1正常两个步骤;
动画:-amp开始8s步骤(1,结束)0s 1正常两者
}
@-webkit关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@-moz关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@-ms关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@-o关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
@关键帧-amp开始{
从{
可见性:隐藏
}
到{
可见性:可见
}
}
身体{
-webkit动画:无;
-moz动画:无;
-ms动画:无;
动画:无
}
标签{
字体大小:粗体;
}
[role=“listitem”]{
显示器:flex;
}
[role=“listitem”]>*{
弹性:100;
}
安培表{
利润率:10px 20px;
最小宽度:240px;
}
国家:
选择国家
{{{#数据}
{{text_val}}
{{/data}
城市:
{{{#数据}
{{text_val}}
{{/data}

使用您的域更改example.com

这是我正在使用的jquery级联下拉列表的示例url@bachachasingh it i working fine.你能解释一下你做了什么吗请从anwser中删除请求url.让它们***从应答中删除url,我在你的代码1中做了一些小改动。on=“change:AMP.setState({cities:event.value})”2。{{text_val}}3。[src]=“”