Set textbox attribute

Hi, I trying to set a value to a textbox value with below syntax in a Javascript snippet. It works and store the value if I only have the single code alone in a javascript snippet. But if I put other javascript code in the javascript snippet I get "undefiened set".   Any ideas how to solve this?  this._contextObj.set(‘WeightAttr’, value);   Kr Thomas
2 answers

Hi Thomas,

What are you trying to accomplish? If you just need to store the value from a (range) slider, you could also use one of the marketplace widgets for this, so you do not need any custom javascript code.

If you do need to use javascript for this: the issue with the second code snippet you provided in the comment above is that you now use the ‘this’ keyword within a function. Because of that it does no longer point towards the same widget context anymore. You can fix this by assigning the context object to a variable first, like this:

var btn = document.querySelector('.ButtonClass');
var contextObj = this._contextObj;

btn.addEventListener('click', function(event) {
    var RS = rangeSlider.value;
    contextObj.set('WeightAttr', value);


Hope this helps!


So this works fine: “ this._contextObj.set(‘WeightAttr’, value);”. But when you get the error, what is the javascript that you try. And where do you try it.

Try to see what response you get if you only say “this._contextObj”. Should give you an object that facilitates the ‘set’ function.