Click here to Skip to main content
15,902,832 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
<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>
Posted
Comments
gnani_pal 15-May-14 2:08am    
i tried like this , but if i select the first combo box also pop-window is coming , and remaining duplication is working fine, but when pop-window is coming but text is not changing sir, can you tell me , after pop-window, the combo box text should be like this --Select--. plz

<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 && cbAuth2.value!==0 ) {
alert("Authoriser1 and Authoriser2 should not match, Okay");
return false;
}

if (cbAuth2.value == cbAuth3.value ) {
alert("Authoriser2 and Authoriser3 should not match ");
return false;
}

if (cbAuth3.value == cbAuth1.value ) {
alert("Authoriser1 and Authoriser should not match ");
return false;
}

return true;
}
</script>

<telerik:RadComboBox runat="server" ID="cbAuthoriser1" Width="250px" EmptyMessage="Selct" AutoPostBack="true" önchange='onChange();'>


<telerik:RadComboBox runat="server" ID="cbAuthoriser2" Width="250px" EmptyMessage="Selct" AutoPostBack="true" önchange='onChange();'>


<telerik:RadComboBox runat="server" ID="cbAuthoriser3" Width="250px" EmptyMessage="Selct" AutoPostBack="true" önchange='onChange();'>

This approach should work but there is one issue like, as per your description no one combobox value should match with any other combobox. In this perspective the condition checkings should be done as '||' rather than '&&'.

Because in this case if the current combobox value matches with both of them then only your message will display whereas you want it to view when it matches with any one of them.

Again you can set its selected index to 0 when it matches.
Ex -
JavaScript
cbAuth1.selectedIndex = 0;


Hope this makes sense and will be of help.
 
Share this answer
 
v2
ASP.NET
<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

JavaScript
<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>
 
Share this answer
 
v3
Comments
gnani_pal 15-May-14 2:48am    
No sir it's not working, actually its working fine but when i select the first one also the pop-window is coming. and text is not changing, what ever i am selecting that record is displaying sir, but duplication is working fine
DamithSL 15-May-14 2:53am    
i have added full script, test with that
gnani_pal 15-May-14 2:53am    
actually its working fine but when i select the first one also the pop-window is coming. and text is not changing, what ever i am selecting that record is displaying sir, but duplication is working fine

yah i tried your script only sir, i already changed
gnani_pal 15-May-14 2:57am    
now i am trying this code
actually its working fine but when i select the first one also the pop-window is coming. and text is not changing, what ever i am selecting that record is displaying sir, but duplication is working fine

<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);">



<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");
obj.selectedIndex =0;
return false;
}

if (cbAuth2.value == cbAuth3.value ) {
alert("Authoriser2 and Authoriser3 should not match ");
obj.selectedIndex =0;
return false;
}

if (cbAuth3.value == cbAuth1.value ) {
alert("Authoriser1 and Authoriser should not match ");
obj.selectedIndex =0;
return false;
}

return true;
}
</script>
gnani_pal 15-May-14 3:30am    
when i select the first one also the pop-window is coming. and text is not changing, if i want to change the text is " " , what code i have to write in javascript

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900