How to pass parameters from one function to another?
Follow the code:
<body onload="getfoucs()">
<select id="select_compra" data-limit="3">
<option disabled selected style="display: none">Aaaaaaaaaaaaa</option>
<option>Bbbbbbbbb</option>
<option>Ccccccc</option>
<option>Ddddddddddd</option>
</select>
<script>
function datalimit(limit)
{
var selects = document.querySelectorAll('[data-limit]');
[].forEach.call
(
selects, function(select)
{
var limit = select.getAttribute('data-limit');
[].forEach.call
(
select.options, function(option)
{
var text = option.innerHTML.substring(0, limit);
option.innerHTML = text;
}
);
}
);
}
function getfoucs()
{
datalimit();
select_compra.addEventListener
(
'change', function()
{
datalimit(50);
/*
Como eu altero o valor de "limit" e
Chamo novamente a função datalimit()
*/
}
);
}
</script>
</body>
change
the value of limit
is changed to behave more characters and later when the select
loses the focus
back to the initial value that is 3
(but let's break it down).