gpt4 book ai didi

javascript - 下拉列表的选定项目在同一页面上显示文本

转载 作者:行者123 更新时间:2023-12-03 10:11:01 26 4
gpt4 key购买 nike

您好,我想在用户选择下拉列表中的一项时显示文本。默认情况下,页面上显示所有文本,但如果用户从下拉列表中选择一个项目,则只有焦点转到特定文本部分。在代码中,如果我选择“a”项目,则页面焦点将转到“a”项目文本。我不知道如何用 javascript 做到这一点,任何人都可以帮助我。

<html>
<head>
<script type="text/javascript" language="javascript">
function ChangeText()
{
var parm = document.getElementById("mySelection");
document.getElementById('lbltxt').innerHTML = parm.options[parm.selectedIndex].text;

}
</Script>
</head>
<body>
<select id="mySelection" onchange="Return ChangeText();" style="width:30%;">
<option disabled="disabled" selected="selected">Select method</option>
<option value="1">a (new version)</option>
<option value="2">b (old version)</option>
<option value="3">c</option>
</select>

<b><label id="lblid" /></b><br /><br />
<strong id="1">A(For new versions)</strong><br />
In a, This can be done by denying the OPTIONS verb from the HTTP Verb Request Filtering rules in IIS.Following is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML content<br />

<img src="images/1.png" style="float:left;"><img style="float:left;" src="images/arrow_up.png" width="62" height="60">Following is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML content<br />
<br />
<strong id="2">b (For old versions)</strong><br />
for B :<br />
Following is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML content
<img src="images/2.png">Following is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML content<br /><br />
<strong id="3">C</strong><br />
<p style="text-align:justify; font-size:17px;">Following is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML contentFollowing is an example which makes use of .html() and .text(val) methods. Here .html() retrieves HTML content</p>
</body>
</html>

最佳答案

首先,您应该在下拉菜单的 OnChange() 事件中调用 JavaScript 函数然后您可以在所需文本的位置添加标签。您可以为标签设置页面加载(所有项目)的文本。然后,在 javascript 中(下拉列表更改时调用),您可以根据下拉选择更改标签文本。

在页面加载本身中,您可以根据需要为标签分配值。

            		function ChangeText()
{
var contentText;
var selectedITem='';
var parm = document.getElementById("mySelection");
selectedITem =parm.options[parm.selectedIndex].text;
if(selectedITem == 'a')
contentText = 'Type What you want for option A'
else if(selectedITem == 'b')
contentText = 'Type What you want for option B'


str='<tr> <td>' + contentText +' </td> </tr>';
$("#test").append(str);


}
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<table id="test">

<tr>

<td width="40%" align="left">

<select id="mySelection" onchange="ChangeText();" style="width: 100%;">

<option disabled="disabled" selected="selected">Select method</option>
<option value="1">a</option>
<option value="2">b</option>
<option value="3">c</option>
</select>
&nbsp;&nbsp;&nbsp;
</td>


</tr>

</table>

关于javascript - 下拉列表的选定项目在同一页面上显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30115846/

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