I worked this out for you. Take a look at the code.
JavaScript code
<script type="text/javascript">
// Function is used to select the DropDown Paid value
// if textbox contains any value.
function SelectPaidValue() {
// Get the controls.
var textPaid = document.getElementById('<%=textPaid.ClientID%>');
var ddlPaymentStatus = document.getElementById("<%=ddlPaymentStatus.ClientID %>");
// Check if data is there in textbox or not
if (textPaid.value != "" && textPaid.value != null) {
// If data is there select "Paid" from DropDownList.
selectItemByValue(ddlPaymentStatus, 1);
}
else {
// If data is not there, then select "--Select--" from DropDownList.
selectItemByValue(ddlPaymentStatus, 4);
}
}
// Function is used to select the DropDown option by value.
function selectItemByValue(elmnt, value) {
// Loop through all the options and select the provided value.
for (var i = 0; i < elmnt.options.length; i++) {
if (elmnt.options[i].value == value)
elmnt.selectedIndex = i;
}
}
</script>
aspx code
<asp:TextBox ID="textPaid" runat="server" onblur="SelectPaidValue()"></asp:TextBox>
<asp:DropDownList ID="ddlPaymentStatus" runat="server">
<asp:ListItem Value="4">--Select--</asp:ListItem>
<asp:ListItem Value="0">Open</asp:ListItem>
<asp:ListItem Value="1">Paid</asp:ListItem>
<asp:ListItem Value="2">Pending</asp:ListItem>
<asp:ListItem Value="3">Advance</asp:ListItem>
</asp:DropDownList>
Thanks...