How to get the input value into the java script snippet

Hi , I am using JavaScript Snippet in page and i am giving class name , now the snippet is working fine but i want to get the value what was entered on the page . I am unable to retrieve the value using class name . Options i selected in widget is enable Jquery : jquery1.12.4 enable refresh : yes     
4 answers

Just to be clear – you’re trying to capture the value of a Mendix input field into your JS code?

If so, you want to look at this, I think

Since you’re searching on class, you’d need to query using document.getElementsByClassName("example")[0], assuming you ensure that the class is only used once in that page.

Hope this helps!


using the set attribute widget from the app store and then by creating the set attributes you cna give the desired values to the desired variables in your javascript snippet



I am unable to get the values entered in the input text field in mendix page into java script snippet .

I also want the the selected boolean value in mendix page into the java script 

I am using the JavaScript Snippet

Please find the below screen shots 




The java script i have written in this is as below 



alert('hi ');

alert('class names ------ '+this.className);

alert('entered value '+$(this).val());




I am getting class name as form-group mx-name-textBox4 cityName in alert box and i am not getting any entered value . 


i also tried $(‘.myclassName’).val();


but the O/P is not coming 




Use the Javascript widget (Data source) instead.

In the widget you can define a variable, associated to the relevant attribute, let's say ‘varX’.

Then the only thing you have to do for using this variable in the JS is (for example):

var value = "${varX}";
if (value.length > 99) {
  // some magic
else {
  // some other magic

By the way: using of JQuery is not recommended, and certainly not v1.12.4