I have a dropdownlist that I want to wrap in a span.
What I would like to happen is…
When a user selects a new item from the dropdownlist, the span will check a js function and accept a return value of true/false.
If the span value = true then let the user continue with the selection, otherwise cancel selection and return the dropdownlist selected value to -1.
I have looked at many examples for the span tag but haven’t been able to find something that will return a value.
How can I get this to work?
Thanks
<span ????>
<asp:DropDownList ID="ddSelectFormula" runat="server"
AppendDataBoundItems="true" AutoPostBack="false" CssClass="controltext"
DataSourceID="lnqSelectFormula" DataTextField="FormulaName"
DataValueField="FormulaID">
<asp:ListItem Selected="True" Text="Select Formula" Value="-1"> </asp:ListItem>
</asp:DropDownList>
</span>
function checkFormulaID() {
var hi = document.getElementById("ctl00_ContentPlaceHolder1_HiFormulaIDList").value;
var dd = document.getElementById("ctl00_ContentPlaceHolder1_ddSelectClientFormula").value;
var ddVal = dd.options[dd.selectedIndex].value;
if (hi > 0 && ddVal > 0) {
var retVal = confirm("Do you want to replace the current formula with this one?");
if (retVal == true) {
return true;
};
} else {
return false;
}
}
Your dropdownlist just needs to include
You may also have to edit your JS for the comparison if (hi > 0 && ddVal > 0) since JS can do crazy things with the value propery.