Galerinha, boa tarde !!
Tenho três check’s.
Se for Usb ou Fax vá fazer um devido processo.
Se Rede escolha ou do tipo dinâmica ou estática.
A usb/fax e dinâmica estão funcionando…
Os meu valores não estão mais predefinidos como eu havia colocado nos values do meu atributos em: html.
Segue linha de codigo em javascript :
<script type="text/javascript">
$(function () {
$("input[name=imp_tx_tipo]").change(function (data) {
var selection = $("input[name=imp_tx_tipo]:checked").val();
console.log(selection);
if (selection != "REDE")
$("#campo-escondido").hide();
else
$("#campo-escondido").show();
});
//$("#campo-escondido").hide();
$("input[name=imp_tx_tipo_ip]").change(function (data) {
var selection = $("input[name=imp_tx_tipo_ip]:checked").val();
console.log(selection);
if (selection != "E")
$("#mostrar_campo").hide();
else
$("#mostrar_campo").show();
if (selection != "D")
$("#dmostrarcampo").hide();
else
$("#dmostrarcampo").show();
});
$("#dmostrarcampo").hide();
$("#mostrar_campo").hide();
$("#campo-escondido").hide();
});
</script>
Segue linhas de código em html:
@{string D = ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId("D"); } @Html.RadioButtonFor(model => model.imp_tx_tipo_ip, "D", new { id = D, name = "imp_tx_tipo_ip", value = "D" }) DINAMICO:
@{string E = ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId("E"); } @Html.RadioButtonFor(model => model.imp_tx_tipo_ip, "E", new { id = E, name = "imp_tx_tipo_ip", value="E" }) ESTATICO:
@Html.ValidationMessageFor(model => model.imp_tx_tipo_ip, "", new { @class = "red-text text-darken-2" }) <div class="row">
<div class="input-field col s2">
<label for="imp_nm_mac_wifi">MAC WIFI:<span class="required"></span></label>
</div>
<div class="input-field col s3">
@*<input type="text" id="wifi" placeholder="INFORME MAC WI-FI" name="imp_nm_mac_wifi" title="MAC WI-FI" class="form-control" />*@
@Html.EditorFor(model => model.imp_nm_mac_wifi, new { htmlAttributes = new { @id = "wifi", @class = "form-control", @placeholder = "INFORME MAC WI-FI", @title = "MAC WI-FI", type = "text" } })
</div>
</div>
<div>
@Html.ValidationMessageFor(model => model.imp_nm_mac_wifi, "", new { @class = "red-text text-darken-2" })
</div>
<div class="row">
<div class="input-field col s2">
<label for="imp_nm_mac_ethernet">MAC ETHERNET:<span class="required"></span></label>
</div>
<div class="input-field col s3">
@*<input type="text" id="ethernet" placeholder="INFORME MAC ETHERNET" name="imp_nm_mac_ethernet" title="MAC ETHERNET" class="form-control" />*@
@Html.EditorFor(model => model.imp_nm_mac_ethernet, new { htmlAttributes = new {@id="ethernet", @class = "form-control", @placeholder = "INFORME MAC ETHERNET", @title = "MAC ETHERNET", type = "text" } })
</div>
</div>
<div>
@Html.ValidationMessageFor(model => model.imp_nm_mac_ethernet, "", new { @class = "red-text text-darken-2" })
</div>
</div>
<div id="mostrar_campo" class="col s12">
<div class="row">
<div class="input-field col s2">
<label for="imp_nm_ip">IP:<span class="required"></span></label>
</div>
<div class="input-field col s3">
@*<input type="text" id="ip" placeholder="INFORME IP" name="imp_nm_ip" title="IP" class="form-control" />*@
@Html.EditorFor(model => model.imp_nm_ip, new { htmlAttributes = new { id="ip",@class = "form-control", @placeholder = "INFORME IP", @title = "IP", type = "text" } })
</div>
</div>
<div>
@Html.ValidationMessageFor(model => model.imp_nm_ip, "", new { @class = "red-text text-darken-2" })
</div>
<div class="row">
<div class="input-field col s2">
<label for="imp_nm_mac_wifi">MAC WIFI:<span class="required"></span></label>
</div>
<div class="input-field col s3">
@*<input type="text" id="_wifi" placeholder="INFORME MAC WI-FI" name="imp_nm_mac_wifi" title="MAC WI-FI" class="form-control" />*@
@Html.Editor("imp_nm_mac_wifi", new { htmlAttributes = new {id="_wifi", @class = "form-control", @placeholder = "INFORME MAC WI-FI", @title = "MAC WI-FI", type = "text", value="99:99:99:99:99:99"} })
</div>
</div>
<div>
@Html.ValidationMessageFor(model => model.imp_nm_mac_wifi, "", new { @class = "red-text text-darken-2" })
</div>
<div class="row">
<div class="input-field col s2">
<label for="imp_nm_mac_ethernet">MAC ETHERNET:<span class="required"></span></label>
</div>
<div class="input-field col s3">
@*<input type="text" id="_ethernet" placeholder="INFORME MAC ETHERNET" name="imp_nm_mac_ethernet" title="MAC ETHERNET" class="form-control" />*@
@Html.Editor("imp_nm_mac_ethernet", new { htmlAttributes = new {id="_ethernet", @class = "form-control", @placeholder = "INFORME MAC ETHERNET", @title = "MAC ETHERNET", type = "text" } })
</div>
</div>
<div>
@Html.ValidationMessageFor(model => model.imp_nm_mac_ethernet, "", new { @class = "red-text text-darken-2" })
</div>
</div>
</div>
Segue imagem: