BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
HTML:
<div class="control">
<div class="ctrllabel">Select a bike</div>
<input type="text" id="bikeList" />
</div>
JavaScript:
<script type="text/javascript">
var target;
$(function () {
// declaration
BikeList = [
{ empid: "bk1", text: "Apache RTR" }, { empid: "bk2", text: "CBR 150-R" }, { empid: "bk3", text: "CBZ Xtreme" },
{ empid: "bk4", text: "Discover" }, { empid: "bk5", text: "Dazzler" }, { empid: "bk6", text: "Flame" },
{ empid: "bk7", text: "Fazzer" }, { empid: "bk8", text: "FZ-S" }, { empid: "bk9", text: "Pulsar" },
{ empid: "bk10", text: "Shine" }, { empid: "bk11", text: "R15" }, { empid: "bk12", text: "Unicorn" }
];
$('#bikeList').ejDropDownList({
dataSource: BikeList,
fields: { id: "empid", text: "text", value: "empid" }
});
// this code in another function
var dropDown = $("#bikeList").data("ejDropDownList");
dropDown.selectItemByValue("bk7") // doesn't work
dropDown.selectItemByText("Fazzer") // doesn't work
});
</script>
thanks in advance
<script type="text/javascript"> var dropDownObj; $(function () { // declaration BikeList = [ { empid: "bk1", text: "Apache RTR" }, { empid: "bk2", text: "CBR 150-R" }, { empid: "bk3", text: "CBZ Xtreme" }, { empid: "bk4", text: "Discover" }, { empid: "bk5", text: "Dazzler" }, { empid: "bk6", text: "Flame" }, { empid: "bk7", text: "Fazzer" }, { empid: "bk8", text: "FZ-S" }, { empid: "bk9", text: "Pulsar" }, { empid: "bk10", text: "Shine" }, { empid: "bk11", text: "R15" }, { empid: "bk12", text: "Unicorn" } ]; $('#bikeList').ejDropDownList({ dataSource: BikeList, //'empid' attribute is mapped to the 'value' field. fields: { id: "empid", text: "text", value: "empid" } }); }); function setValue() { //Object for Dropdownlist is created dropDownObj = $("#bikeList").data("ejDropDownList"); //Set value to EJ Dropdownlist using public methods dropDownObj.setSelectedValue("bk7"); // Set value in drodownlist based on 'value' field. dropDownObj.setSelectedText("FZ-S"); // Set value in dropdownlist based on 'text' field. //Set value to EJ Dropdownlist using properties. dropDownObj.option("value", "bk7"); //Sets value to dropdownlist based on the field mapped to 'value' field. In case if 'value' field is not specified, value will be set to dropdownlist if the specified value matches the text of the dropdownlist items. dropDownObj.option("text", "Dazzler"); //Sets value to dropdownlist, if the text matches with text of dropdownlist items. } script> |