0
I’m new in the area and I’m having a hard time doing the following:
- I made a javascript script to create several copies of mine
option
. So far so good: copies made successfully. - I need to make a
for
in javascript to go through eachoption
copied and left on display in the first line a different sentence for eachoption
.
I thought the following:
for
running through theoption
- Looking for the x phrase in a
option
whichever - Did you find phrase x in
option
: adds aselected
, so that the phrase appears as the first option ofoption
.
Below is the test code of an html with the copy function, for a better understanding:
<!-- ... <html>, <head>, jQuery, etc ... -->
<table cellpadding="10" cellspacing="10" border="1">
<tr>
<td>Lixo01</td>
<td class="Original" id="Linha1">
<select id="MaxAlarme3">
<option value="02">Teste1</option>
<option value="03">Teste2</option>
<option value="0">Teste3</option>
<option value="04">Teste4</option>
</select>
</td>
</tr>
<tr>
<td>Lixo02 teste</td>
<td class="Clonar" id="Linha2"></td>
</tr>
<tr>
<td>Lixo03 value 05</td>
<td class="Clonar" id="Linha3"></td>
</tr>
<tr>
<td>Lixo04</td>
<td class="Clonar" id="Linha4"></td>
</tr>
<tr>
<td>Lixo05</td>
<td class="Clonar" id="Linha5"></td>
</tr>
<tr>
<td>Lixo06</td>
<td class="Clonar" id="Linha6"></td>
</tr>
</table>
<script>
//variavel contar o tamanho das copias
$(document).ready(function() {
//Copia valor da Linha1.Classe
var Copiar = $("#Linha1.Original").html();
//Clona o valor da Linha 1 para a Classe Clonar
$(".Clonar").append(Copiar);
});
</script>
Post the code where you tried to do it.
– Silvio Andorinha
I don’t understand... you just want to set the OPTION that will be selected in SELECT?
– Daniel T. Sobrosa
Good morning. Silvio Andorinha, so I can’t post the code to the company :(
– Jessi
Good morning Daniel T. Sobrosa.I want each copied option to start with a different sentence. I will post a test html so that you can understand better, as I cannot post the original code.
– Jessi
@user5946, when putting some code, select it and click on the icon { } to format it.
– rray
Why I like to post the code on Jsfiddle: first thing I do is press Tidyup.
– Gustavo Rodrigues
A thanks centuries light dps, I managed to post html
– Jessi