This is a piece of my HTML code:
<label for="input_train"><script>mountainTrains("all");</script></label>
mountainTrains()
is a javascript function, which returns string. I want this string to be passed as a text of the label element on the website. This piece of code however only results in an empty string, even if mountainTrains()
returns non-empty string. Is there anything wrong about the syntax I'm trying to access javascript function from HTML?
Function definition:
function mountainTrains(par) {
if (par !== 'all') {
return 'One train';
} else {
return 'All trains';
}
}