This is one of the most irritating issues that I encountered in XPages. Again XPages are not the ones to be blamed, it was me- did not understand how the elements got rendered on the browser.
The issue in short is that I was not able to retrieve or set value to a Computed Field on an XPage using client script
Say my field name on the XPage is "XPageEditBox"
now, document.getElementById("#{id:XPageEditBox}").value did not help me to get or set the values of the edit box.
This was because, I though that the edit box will be rendered as a html field and that was not the case. It was rendered as a span tag.
So the way to access the values is as follows,
var myValue=document.getElementById("#{id:XPageEditBox}").innerHTML to get and
document.getElementById("#{id:XPageEditBox}").innerHTML=myValue to set
Hope this helps :)
The edit box is actually a dijit Widget. So you can use dijit.byID
ReplyDeleteNot sure when you need to use dojo and when to use dijit, I guess dojo will work as well.
ReplyDeletevar d = dojo.byId("#id:inputbox}");
dojo.attr(d,"value","yourvalue")
typo...
ReplyDeletevar d = dojo.byId("#{id:inputbox}");
dojo.attr(d,"value","yourvalue")
Thanks so much... I was struggling with this for days
ReplyDeleteIf possible, share any other issues that you may have struggled with or are struggling with.
ReplyDeleteThanks so much I was struggling before I saw your answer
ReplyDeleteThanks so much!!! From Uruguay. South America (Luis Suarez - Barcelona).
ReplyDelete