gpt4 book ai didi

javascript - 如何获取下拉值变化的下拉数据?

转载 作者:行者123 更新时间:2023-12-03 02:24:06 24 4
gpt4 key购买 nike

您能告诉我如何获取下拉值更改时的下拉数据吗?我正在使用此链接来制作链接下拉列表

https://ampbyexample.com/advanced/linked_dropdowns/这是我的代码

当我选择第一个选项(ZILA SAHAKRI BANK LIMITED GHAZIABAD)时。我希望从此网址的第二个下拉列表中加载数据

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>

最佳答案

尝试一下:

<!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>

将 example.com 更改为您的域名

关于javascript - 如何获取下拉值变化的下拉数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49027426/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com