23
Views
6
Comments
Pass local variable id to document.getElementById()

In FrontEnd Developer Specialist Guided path, under Javascript in Outsytems section, in Javascript API Excercise, we are told to pass the local variable to input parameter of js snippet, however, it is not working as expected.

Hence, I modified the code a bit and it is working fine. I have added an image for the reference


Thank you,

Mayur



JsAPI.png
2024-03-22 09-17-23
Chandra Vikas Sharma

Hi mayur,

can you share the code snippet which is not working. below is the format to pass local variable in javascript.


var inlocalValue = document.getElementById($parameters.InputWidgetID).value;


thanks

cv


2024-04-18 08-00-54
Mayur Shrirame

Hi Chandra, 

Thank you for the response. I found the solution to it.

2019-01-07 16-04-16
Siya
 
MVP

I'm not sure what went wrong in your case. I've created the exact same exercise, and it's working as expected. I've attached a screen recording for your reference. Please compare it with yours to identify and resolve the issue.

JSParam.mp4
2024-04-18 08-00-54
Mayur Shrirame

Thank you Siya for the quick response. However, according to the video you posted, the container is hidden. I was trying to remove the text inside input widget. 

2019-01-07 16-04-16
Siya
 
MVP

Could you please confirm which section of the this assignment you are referring to ?

if you want to set the value of the Text widget inside the MyContainer first of all you need to set an Id for "Text" widget add the below in JS

var element = document.getElementById($parameters.WidgetIdentifier);if(element !== null){element.innerText = "";}

2024-04-18 08-00-54
Mayur Shrirame

Yes I understood, Siya. I was trying to remove the text content of the input field.

Thank you for the help.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.