1
I need a code that I put the URL and number of repetitions in the input and when to click to generate the sequence exit like this in the textarea:
rede[0]="http://www.siteescolhidoaqui"; rede[1]="http://www.siteescolhidoaqui"; rede[2]="http://www.siteescolhidoaqui"; rede[3]="http://www.siteescolhidoaqui"; rede[4]="http://www.siteescolhidoaqui"; rede[5]="http://www.siteescolhidoaqui";
this way up starting at zero until the number chosen by me and always the same url chosen... javascript and a mini html form to put the URL and the number of repetitions... I believe it’s easy, someone can help me?
I tried the one that Renan commented on and I got:
<script>
(function() {
document.querySelector('button').addEventListener('click', toTextarea);
function toTextarea() {
var $urlInput = document.querySelector('input[type="url"]'),
url = $urlInput.value,
inputName = $urlInput.getAttribute('name'),
repeat = document.querySelector('input[type="number"]').value;
if (url && repeat) {
var output = '';
for (var i = 0; i < repeat; i++)
output += inputName + '[' + i + ']="' + url + '"; ';
document.querySelector('textarea').textContent = output;
}
}
})();
</script>
<input placeholder='URL' type='url' name='rede'>
<input placeholder='Sequencia' type='number'>
<button>Ir</button>
<textarea placeholder='Resultado'></textarea>
That’s exactly what it looks like, but it’s not working out here, so when I click go nothing comes out of the result
– Guilherme
Here where? I tested in Firefox, Chrome, IE and Edge, in all of them is working.
– Renan Gomes
I use Firefox and Opera to send you an email if you’re right please
– Guilherme