0
As I put the value of const links to pull from my "textarea" tag, the code works as expected, runs on the right console, but I want that instead of putting the information in the const links, the user can put in the "textarea" inpu field and appear on the screen. Someone knows how to do it?
function myFunction() {
var elemento = document.getElementById("myTextarea").value;
const links = ['https://www.devs.com/produto/chave1', 'https://www.devs.com/produto/chave2'];
const chaves = links.map((link) => link.split('/')[link.split('/').length - 1]);
console.log(chaves);
}
<!DOCTYPE html>
<html>
<body>
<h3>A demonstration of how to access a TEXTAREA element</h3>
Address:<br>
<textarea id="myTextarea">
</textarea>
<p>Click the button to get the content of the text area.</p>
<button type="button" onclick="myFunction()" >Try it</button>
<p id="demo"></p>
</body>
</html>
Would the array be typed in the same format as a javascript expression? If so, you can convert it to json. Eval would also be an option if this does not pose a security threat.
– user142154