问题描述
我有3个组合框,已经在我的数据库中有记录,它出现在组合框中,所以这里的事情是我必须在每个组合框中选择一个记录。但是没有一个组合框记录不能与另一个组合框记录匹配,如果它匹配我想要一个小弹出窗口,文本应该改为--select--,它是使用asp的vb.net中的web应用程序。 net
实际上我正在尝试这样的它是corrt?
给我任何优惠请
i have 3 combo boxes , already i have records in my database, it is appearing in to the combo boxes, so here thing is i have to select one record in each combo box. but no one combo box record should not match with the another combo box record, if it matches i want one small pop up window, and text should be change to --select--, it is web application in vb.net using asp.net
actually i am trying like this is it corrt?
given me any sucessions please
<script type ="text/javascript" >
function onChange() {
var cbAuth1 = document.getElementById('<%=cbAuthoriser1.ClientId%>');
var cbAuth2 = document.getElementById('<%=cbAuthoriser2.ClientId%>');
var cbAuth3 = document.getElementById('<%=cbAuthoriser3.ClientId%>');
if (cbAuth1.value == cbAuth2.value && cbAuth1.value == cbAuth3.value) {
alert("Authoriser2 and Authoriser3 should not match with Authoriser1");
return false;
}
if (cbAuth2.value == cbAuth1.value && cbAuth2.value == cbAuth3.value) {
alert("Authoriser1 and Authoriser3 should not match with Authoriser2");
return false;
}
if (cbAuth3.value == cbAuth1.value && cbAuth3.value == cbAuth2.value) {
alert("Authoriser1 and Authoriser2 should not match with Authoriser3");
return false;
}
return true;
}
</script>
<telerik:RadComboBox runat="server" ID="cbAuthoriser1" Width="250px" EmptyMessage="Selct" AutoPostBack="true" onchange='onChange();'>
</telerik:RadComboBox>
<telerik:RadComboBox runat="server" ID="cbAuthoriser2" Width="250px" EmptyMessage="Selct" AutoPostBack="true" onchange='onChange();'>
</telerik:RadComboBox>
<telerik:RadComboBox runat="server" ID="cbAuthoriser3" Width="250px" EmptyMessage="Selct" AutoPostBack="true" onchange='onChange();'>
</telerik:RadComboBox>
推荐答案
cbAuth1.selectedIndex = 0;
希望这是有道理的并且会有所帮助。
Hope this makes sense and will be of help.
<telerik:radcombobox runat="server" id="cbAuthoriser1" width="250px" emptymessage="Selct" autopostback="true" önchange="onChange(this);" xmlns:telerik="#unknown">
<telerik:radcombobox runat="server" id="cbAuthoriser2" width="250px" emptymessage="Selct" autopostback="true" önchange="onChange(this);">
<telerik:radcombobox runat="server" id="cbAuthoriser3" width="250px" emptymessage="Selct" autopostback="true" önchange="onChange(this);"></telerik:radcombobox></telerik:radcombobox></telerik:radcombobox>
现在更改脚本签名以接受对象
now change the script signature to accept the object
<script type ="text/javascript" >
function onChange(obj) {
var cbAuth1 = document.getElementById('<%=cbAuthoriser1.ClientId%>');
var cbAuth2 = document.getElementById('<%=cbAuthoriser2.ClientId%>');
var cbAuth3 = document.getElementById('<%=cbAuthoriser3.ClientId%>');
if (cbAuth1.value == cbAuth2.value && cbAuth2.value!==0 ) {
alert("Authoriser1 and Authoriser2 should not match, Okay");
SelectFirstItem(obj);
return false;
}
if (cbAuth2.value == cbAuth3.value ) {
alert("Authoriser2 and Authoriser3 should not match ");
SelectFirstItem(obj);
return false;
}
if (cbAuth3.value == cbAuth1.value ) {
alert("Authoriser1 and Authoriser should not match ");
SelectFirstItem(obj);
return false;
}
return true;
}
function SelectFirstItem(combo) {
combo.trackChanges();
combo.get_items().getItem(0).select();
combo.updateClientState();
combo.commitChanges();
}
</script>
这篇关于我将如何在Vb.Net或Javascript中验证3个组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!