-3
I made a post on how with a choice, select all the items. I received a reply, which solved. well, solved only in Chrome, but in IE does not work. As the question changed the "direction", so I decided to do another post. Includes other versions of jquery and it still didn’t work. This is the code of my select(html).
<tr>
<td width="10%" class="label_right">Autorização Prévia: </td>
<td class="label_left">
<select id="ddl_autorizacaoprevia" multiple="multiple" >
<option value="0">TODAS AS AUTORIZAÇÕES</option>
<option value="T">TÉCNICA / ADMINISTRATIVA</option>
<option value="A">SISTÊMICA</option>
<option value="N">NÃO PRECISA</option>
</select>
</td>
</tr>
This is the jquery that selects all items in a single click:
$('#ddl_autorizacaoprevia option').click(function () {
var that = $(this);
if (that.val() == 0) {
$('#ddl_autorizacaoprevia option').each(function () {
$(this).attr('selected', 'selected');
});
} else {
$('#ddl_autorizacaoprevia option').each(function () {
$(that).removeAttr('selected');
});
$(that).attr('selected', 'selected');
}
});
So, this code works well in Chrome, but it doesn’t work in IE. What can it be? Only works with Ctrl+Click, then I can select all, but only by clicking the first index(index = 0), there not selects all items, but in Chrome works and the browser approved by the company is IE and not Chrome, so I have to make it work in IE.
According to what you described and based on the code you posted, this is the logical behavior that should occur. When you click a value other than ZERO, uncheck all others and mark only what is "clicked". You’re confused in your description about what really doesn’t work or what behavior you want.
– Daniel Omine
Ok, what I mean is that this behavior only works in Google Chrome. In IE it doesn’t work. The code is functional, just not in IE.
– pnet
If I ask a question, wanting two answers, I get downvote and advice to open another post. Then I open another post and receive downvote the same way, because it seems to be a repeated question, for using the same code, but with different question. I wanted to understand.
– pnet
Along those lines
$('#ddl_autorizacaoprevia option').each(function ()
If I remove the option, I can do multiple selection, but only if there is none selected. If I select one and then click on Index Item 0, it no longer works. But if I reload the page (deselecting everything), this way it works. I understood that IE does not "like" the option.– pnet