Is there a way to show text before AND after text entry fields in a Matrix Table (Constant Sum type) | XM Community
Skip to main content
Solved

Is there a way to show text before AND after text entry fields in a Matrix Table (Constant Sum type)

  • June 28, 2021
  • 2 replies
  • 84 views

MatthewM
Level 6 ●●●●●●
Forum|alt.badge.img+30

I am collecting monetary data and trying to display a dollar sign before the field, and ".00" after the field.
image.png
Is there a way to do this entirely with javascript, or with the built-in Add Symbol feature for one side, and Javascript for the other side?

Best answer by ahmedA

This will add it

before
:
document.querySelectorAll("tr input").forEach(item =>{
    item.insertAdjacentText("beforebegin","$ ")})

2 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Answer
  • June 28, 2021

This will add it

before
:
document.querySelectorAll("tr input").forEach(item =>{
    item.insertAdjacentText("beforebegin","$ ")})


MatthewM
Level 6 ●●●●●●
Forum|alt.badge.img+30
  • Author
  • Level 6 ●●●●●●
  • June 29, 2021

Thank you ahmedA ! And if I wanted to make the field 100px wide, what would I add? I've been using the code below previously, and it appears to work OK with your new code, but I'm a Javascript novice and don't know if that's unstable or there's a more efficient way to do this.
image.png