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!
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
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
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