如何更改按钮及其文本的颜色,从部分视图更改为普通视图?
程序员们下午好!对不起,我正在尝试更改颜色,我的问题按钮的文本如下:
当您单击预注册按钮时,在视图中会显示几门课程其中一些向我显示了一个模式,其中有一个处于部分视图中的表单,当您单击“确定”时,您必须将颜色更改为蓝色,并将文本更改为常规视图的“取消”。我怎么能这样做呢?
这是我在概述中找到的 foreach 按钮:
<button type="button" class="boton botonUno btnPreinscribir"id="myButtonChangeF" value="Preinscribirse" title="Preinscribirse" data-url="@Url.Action("PreinscripcionNumCurso","Inicio")" data-id="@ingles.Num" data-toggle="modal" data-backdrop="static">Preinscribir</button>
这是我在部分视图中的表单:
@model MultipleViewModel
@{
Layout = null;
}
@Html.ValidationSummary(true)
<link rel="stylesheet" href="~/css/VentanasParciales.css">
<link rel="stylesheet" href="~/css/FormStyle.css">
<!-- Modal Preinscripción-->
<form class="formulario" asp-controller="Inicio" asp-action="Editar" id="Editarform">
<fieldset>
<legend>Preinscripción</legend>
<p class="estilo">_____________________________</p>
<P class="estilo">
¿Esta seguro de preincribirte al curso de @Model.Curso.NombreCurso? @Model.Curso.Num
</P>
<p class="estilo">_____________________________</p>
<br />
</fieldset>
<div class="modal-footer">
<button type="button" class="btn btn-secondary text-white" data-bs-dismiss="modal">Cancelar</button>
<button type="submit" class="btn btnBgColor text-white">Aceptar</button>
</div>
</form>
这些是我在 Javascript 中用来制作颜色和颜色的函数。文本更改。
function myFunction2() {
var btn = document.getElementById("myButtonChangeF");
if (btn.value == "Preinscribirse") {
btn.value = "Anular";
btn.innerHTML = "Anular";
btn.setAttribute("style", "background: linear-gradient(135deg, #24309d, #96989A);");
}
else {
btn.value = "Preinscribirse";
btn.innerHTML = "Preinscribirse";
btn.setAttribute("style", "background: linear-gradient(135deg, #9d2449, #96989A);");
}
}
感谢您的支持!
Good afternoon programmers! Excuse me I’m trying to change the color and the text of a button of my problem is as follows:
In a view several courses are displayed, when you click on the preregister button of some of them shows me a modal and inside this a form that is in a partial view, when you click OK you must change the color to blue and the text to "Cancel" of the General view. How could I do this?
Here is my foreach button found in the overview:
<button type="button" class="boton botonUno btnPreinscribir"id="myButtonChangeF" value="Preinscribirse" title="Preinscribirse" data-url="@Url.Action("PreinscripcionNumCurso","Inicio")" data-id="@ingles.Num" data-toggle="modal" data-backdrop="static">Preinscribir</button>
This is my form that’s in the partial view:
@model MultipleViewModel
@{
Layout = null;
}
@Html.ValidationSummary(true)
<link rel="stylesheet" href="~/css/VentanasParciales.css">
<link rel="stylesheet" href="~/css/FormStyle.css">
<!-- Modal Preinscripción-->
<form class="formulario" asp-controller="Inicio" asp-action="Editar" id="Editarform">
<fieldset>
<legend>Preinscripción</legend>
<p class="estilo">_____________________________</p>
<P class="estilo">
¿Esta seguro de preincribirte al curso de @Model.Curso.NombreCurso? @Model.Curso.Num
</P>
<p class="estilo">_____________________________</p>
<br />
</fieldset>
<div class="modal-footer">
<button type="button" class="btn btn-secondary text-white" data-bs-dismiss="modal">Cancelar</button>
<button type="submit" class="btn btnBgColor text-white">Aceptar</button>
</div>
</form>
And these are the functions I use in Javascript to make color and text changes.
function myFunction2() {
var btn = document.getElementById("myButtonChangeF");
if (btn.value == "Preinscribirse") {
btn.value = "Anular";
btn.innerHTML = "Anular";
btn.setAttribute("style", "background: linear-gradient(135deg, #24309d, #96989A);");
}
else {
btn.value = "Preinscribirse";
btn.innerHTML = "Preinscribirse";
btn.setAttribute("style", "background: linear-gradient(135deg, #9d2449, #96989A);");
}
}
I’d appreciate your support!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
努力寻找你被困在这里的东西......
为了存储用户已注册的课程,您将需要
Struggling to find what you are stuck on here...
In order to store which courses the user has enrolled in you are going to need local storage in your javascript.