Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Issue with Textarea xtype picking value from the JSP

Avatar

Level 10

Hello,

Is there a way to pass a data to a widget in a dialog from the JSP.

I am trying to have the value of the widget(textarea xtype) which is initially hidden, an onclick of a checkox i would have the texarea as xtype shown, bearing the value that is  stored under the dc:description property of a particular asset, which has been dragged and dropped onto the drop target area in the same dialog.

I managed to use selectionchanged listener for the checkbox and i am able to populate the text area with the asset's dc:description value, but if i have multiple such components on the page the first component's dc:description value gets picked up.

In jsp:     <input id ="desc" type ="text" value ="<%=assetDesc%>"/>  //prints the right dc:description values(stored in assetDesc variable) for each component dropped on the page,

in listener: var desc=document.getElementById("desc").value;// always returns the value of the component that has been dropped on the page first.

 

Any help ?

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi,
it will be difficult to use this since you can't really have several elements on a page with the same id (or you can but definitely should not).
You need to create a unique id for each element if you want to user getElementById. Otherwise it will just pick the first element with that id on the page.

/Johan

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

Hi,
it will be difficult to use this since you can't really have several elements on a page with the same id (or you can but definitely should not).
You need to create a unique id for each element if you want to user getElementById. Otherwise it will just pick the first element with that id on the page.

/Johan