How to get the input value into the java script snippet

0
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     
asked
4 answers
0

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

https://www.w3schools.com/jsref/prop_text_value.asp

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!

answered
0

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

https://appstore.home.mendix.com/link/app/5958/TimeSeries/Set-Attribute

answered
0

Hi 

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 https://appstore.home.mendix.com/link/app/43096/Incentro/JavaScript-Snippet

Please find the below screen shots 

 

 

 

The java script i have written in this is as below 

 

$('.cityName').change(function(){

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();

document.getElementsByClassName("example")[0] 

but the O/P is not coming 

 

Thanks 

answered
0

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

 

 

 

answered