dropdownlist 的id aa div的id 是bb $("#aa").change(function(){ var _val=$("#aa").find("option[selected]").text();//显示值,如果是value值就直接$("#aa").val(); $("#bb").html(_val); });
html代码:<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function getthis() { var rtl = document.getElementById("<%=ddl1.ClientID %>"); var s = rtl.options[rtl.selectedIndex].value; document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式 }
<script type="text/javascript"> function getthis() { var rtl = document.getElementById("Select1"); var s = rtl.options[rtl.selectedIndex].value; document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
}
</script> </body> 这个怎么运行不显示啊
html代码:<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function getthis() { var rtl = document.getElementById("<%=ddl1.ClientID %>"); var s = rtl.options[rtl.selectedIndex].value; document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式 }
<script type="text/javascript"> function getthis() { var rtl = document.getElementById("Select1"); var s = rtl.options[rtl.selectedIndex].value; document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
<script type="text/javascript"> function getthis() { var rtl = document.getElementById("Select1"); var s = rtl.options[rtl.selectedIndex].value; document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
<script type="text/javascript"> function getthis() { var rtl = document.getElementById("Select1"); var s = rtl.options[rtl.selectedIndex].value; document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
}
</script> </body> 这个怎么运行不显示啊 你的option中 没有value啊 你是想显示其中的text么 两个是不同的概念有什么办法显示其中的text吗? 就是 <option>11111</option> 中的值 var s = rtl.options[rtl.selectedIndex].value;中的value改为text 。但是onchange这个事件 只是在select选项中的值改变才触发 比如你之前选择的是11111现在又点一次11111 那么就不会触发了 但是你如果现在点22222那么就会触发
var selectvalue = select1.options[select1.selectedIndex].value;
var selectText= select1.options[select1.selectedIndex].text;
document.getElementById('divid').innerHTML = selectText;红色是dropdownlist的id,蓝色是div的ID
$("#DropDownList1").change(function () {
$("#Div1").html($("#Div1").html() + $(this).val());
});
})
document.getElementById('divid').innerHTML = selectvalue;
div的id 是bb
$("#aa").change(function(){
var _val=$("#aa").find("option[selected]").text();//显示值,如果是value值就直接$("#aa").val();
$("#bb").html(_val);
});
<head runat="server">
<title></title>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("<%=ddl1.ClientID %>");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式 }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddl1" runat="server" onchange="getthis()">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:DropDownList>
<div id="div1">
</div>
</div>
</form>
</body>
</html>
document.getElementById("demo").innerText=这个方法 需要 提交才能显示 ,要实时显示的
不知道你的实时是什么意思。 就是dropdownlist修改值后的变化吧。
你用dropdownlist的选中事件去触发js不就实现了么 为什么要提交呢?
<head runat="server">
<title></title>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("<%=ddl1.ClientID %>");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式 }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddl1" runat="server" onchange="getthis()">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:DropDownList>
<div id="div1">
</div>
</div>
</form>
</body>
</html>
<body>
<form id="form1" runat="server">
<div>
<select name="Select1" id="Select1" onchange="getthis()" >
<option>11111</option>
<option>22222</option>
</select>
<div id="div1">
</div>
</div>
</form>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("Select1");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
}
</script>
</body>
这个怎么运行不显示啊
<head runat="server">
<title></title>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("<%=ddl1.ClientID %>");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式 }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddl1" runat="server" onchange="getthis()">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:DropDownList>
<div id="div1">
</div>
</div>
</form>
</body>
</html>
<body>
<form id="form1" runat="server">
<div>
<select name="Select1" id="Select1" onchange="getthis()" >
<option>11111</option>
<option>22222</option>
</select>
<div id="div1">
</div>
</div>
</form>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("Select1");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
}
</script>
</body>
这个怎么运行不显示啊
你的option中 没有value啊 你是想显示其中的text么 两个是不同的概念
<head runat="server">
<title></title>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("<%=ddl1.ClientID %>");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式 }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddl1" runat="server" onchange="getthis()">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:DropDownList>
<div id="div1">
</div>
</div>
</form>
</body>
</html>
<body>
<form id="form1" runat="server">
<div>
<select name="Select1" id="Select1" onchange="getthis()" >
<option>11111</option>
<option>22222</option>
</select>
<div id="div1">
</div>
</div>
</form>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("Select1");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
}
</script>
</body>
这个怎么运行不显示啊
你的option中 没有value啊 你是想显示其中的text么 两个是不同的概念有什么办法显示其中的text吗? 就是 <option>11111</option> 中的值
<head runat="server">
<title></title>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("<%=ddl1.ClientID %>");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式 }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddl1" runat="server" onchange="getthis()">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:DropDownList>
<div id="div1">
</div>
</div>
</form>
</body>
</html>
<body>
<form id="form1" runat="server">
<div>
<select name="Select1" id="Select1" onchange="getthis()" >
<option>11111</option>
<option>22222</option>
</select>
<div id="div1">
</div>
</div>
</form>
<script type="text/javascript">
function getthis() {
var rtl = document.getElementById("Select1");
var s = rtl.options[rtl.selectedIndex].value;
document.getElementById("div1").innerHTML = document.getElementById("div1").innerHTML + s;//没用jquery就用这种方式
}
</script>
</body>
这个怎么运行不显示啊
你的option中 没有value啊 你是想显示其中的text么 两个是不同的概念有什么办法显示其中的text吗? 就是 <option>11111</option> 中的值
var s = rtl.options[rtl.selectedIndex].value;中的value改为text 。但是onchange这个事件 只是在select选项中的值改变才触发 比如你之前选择的是11111现在又点一次11111 那么就不会触发了 但是你如果现在点22222那么就会触发