I need a code that I put the URL and the number of repetitions in the input and when I 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 above starting at zero until the number chosen by me and always the same url chosen ... javascript and a mini form in html to put the URL and the number of repetitions ... I believe it's easy, can anyone help me?
I tried the one that renan commented and I managed:
<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>