Created
June 17, 2011 20:23
-
-
Save MayogaX/1032237 to your computer and use it in GitHub Desktop.
De uma caixa de seleção a outra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @{ | |
| ViewBag.Title = "Tópico"; | |
| Layout = "~/Views/Shared/_Layout.cshtml"; | |
| } | |
| <select multiple="multiple" size="6" id="selectTopicosNaoTema"> | |
| </select> | |
| <input type="button" id="btAddTopico" onclick="AddTopico();" value="Adicionar >>" /> | |
| <input type="button" id="btTirarTopico" onclick="TirarTopico();" value="<< Remover" /> | |
| <select multiple="multiple" size="6" id="selectTopicosDoTema"> | |
| </select> | |
| <script type="text/javascript"> | |
| $(function () { | |
| GetTopicosNaoTema(); | |
| GetTopicosDoTema(); | |
| }); | |
| function GetTopicosNaoTema() | |
| { | |
| var url = '@Url.Action("GetTopicosNaoTema")'; | |
| var option = ""; | |
| $.get(url, function (dados) { | |
| $.each(eval(dados), function (tmp, obj) { | |
| option += "<option value ='" + obj.Id + "'>" + obj.Nome + "</option>"; | |
| }); | |
| $("#selectTopicosNaoTema").html(option); | |
| }); | |
| } | |
| function GetTopicosDoTema() { | |
| var url = '@Url.Action("GetTopicosDoTema")'; | |
| var option = ""; | |
| $.get(url, function (dados) { | |
| $.each(eval(dados), function (tmp, obj) { | |
| option += "<option value ='" + obj.Id + "'>" + obj.Nome + "</option>"; | |
| }); | |
| $("#selectTopicosDoTema").html(option); | |
| }); | |
| } | |
| function AddTopico() { | |
| var topicoSelecionado = $('#selectTopicosNaoTema').find('option').filter(':selected'); | |
| $("#selectTopicosDoTema").append("<option value='" + topicoSelecionado.val() + "'>" + topicoSelecionado.text() + "</option>"); | |
| topicoSelecionado.remove(); | |
| } | |
| function TirarTopico() { | |
| var topicoSelecionado = $('#selectTopicosDoTema').find('option').filter(':selected'); | |
| $("#selectTopicosNaoTema").append("<option value='" + topicoSelecionado.val() + "'>" + topicoSelecionado.text() + "</option>"); | |
| topicoSelecionado.remove(); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment