Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
function myFunc(selection, textBox) {  
  var boxID = textBox.id; 
  alert(boxID)
}

myFunc;  


Note: If the textbox has the float placeholder property enabled, the DOM structure of the textbox widget is altered, in that the textbox's <input> element is wrapped in a <div> element, which then adopts the widget's id. In this case, the onselect event handler could be written like in Example 3, below.

Example 3: (Same as Example 2, but supports widgets using floating placeholders)

Code Block
languagejs
function myFunc(selection, textBox) {
  var boxID;
  if (textBox.classList.contains("pui-floating-placeholder-input")) boxID = textBox.parentElement.id; // If floating placeholder exists, get the id from the parent div
  else boxID = textBox.id;
  
  alert(boxID);
}
 
myFunc;