I have customized a newform.aspx page for a list. The form has a couple of BDC fields, one of which I'm trying to set a default value. I have a javascript using jquery that sets the default value of several regular text fields but I cannot get the function to work with the BDC field. I have the following code:
function setDefault() {
var variety = "blue";
var elem = getBDCTagFromIdentifierAndTitle("TEXTAREA","Object Picker", 1);
if(elem) elem.value = variety;
var elem = getBDCTagFromIdentifierAndTitle("DIV","Object Picker", 1);
if(elem) elem.innerText = variety;
}
function getBDCTagFromIdentifierAndTitle(tagName, title, count) {
var tags = document.getElementsByTagName(tagName);
var myCount = 0;
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title){
myCount++;
if(count == myCount){
return tags[i];
}
}
}
return null;
}
This shows the value in the field, but when I save the form, the field does not save the value. My regular text fields that have a default value set do save, just not the BDC field. I've verified that the getBDCTagFromIdentifierAndTitle function does return valid objects and their value/innerText are indeed being set.
Any suggestions? is there a better way of setting the default value of a BDC field?
Moved byMike