How to reset the lookup value to None in Editform.aspx page using Jquery.
I want to empty the lookup dropdown if text box does not have any value . Here is the code which i have tried.I was able to set the value but it is adding ('None') in the look up drop down. When i click on save it is showing the selected value .
Note: By lookup has more than 20+ items.
$("input[title='"+NumStoreColName+"']").change(function()
{
var NoStoreVals =$("input[title='"+NumStoreColName+"']").val();
if(NoStoreVals == "")
{
ResetDropDownList(hidelookup);
}
else
{
}
});
function ResetDropDownList(lookupcolumnName)
{
lookupField = getField('select',lookupcolumnName);
lookupSelectedItem = lookupField.options[lookupField.selectedIndex];
var test= lookupSelectedItem.value + "-" + lookupSelectedItem.text;
lookupSelectedItem.text='(None)';
}
function getField(fieldType,fieldTitle) {
var docTags = document.getElementsByTagName(fieldType);
for (var i=0; i < docTags.length; i++) {
if (docTags[i].title == fieldTitle) {
return docTags[i];
}
}
return false;
}