【问题标题】:How to highlight a filed cell when user clicks on a button用户单击按钮时如何突出显示已归档的单元格
【发布时间】:2016-11-10 11:11:24
【问题描述】:

我已经建立了一个系统,允许客户完成问卷调查。为了完成问卷,用户必须输入他们的唯一编号,该编号使用存储过程从不同的数据库中提取他们的数据。

无论如何,我想要做的是当客户完成他们的调查问卷并点击创建 id,例如要突出显示的单元格/字段集,以便我知道哪个客户完成了调查问卷。

仍在改进我的前端开发,但需要一些帮助。我只发布了我的前端(视图)代码,因为这是需要完成工作的地方。

谁能指导我使用 javascript/Jquery

<fieldset style="width:1200px;">
    <legend>StoreQuestions</legend>
    @Html.HiddenFor(model => model.storeId)
    <div class="editor-label">
        <h3>What condition was your Item in when you received it? (1 - Very Poor, 2 - Standard, 3 - Good , 4 - Excellent)</h3>
    </div>

 <input type="submit" value="Create" class="button">

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(StoreQuestions storequestions)
{
        if (ModelState.IsValid)
        {
            db.StoreQuestions.Add(storequestions);
            db.SaveChanges();
            return RedirectToAction("Details", "Questions", new { id = storequestions.QuestionsId });
        }

        return View(storequestions);
}

【问题讨论】:

  • 点击提交按钮后是否要突出显示editor-label div?
  • 是的,我希望它发生

标签: javascript jquery q asp.net-mvc-views


【解决方案1】:

从未测试过代码,但是:

<fieldset style="width:1200px;">
    <legend>StoreQuestions</legend>
    @Html.HiddenFor(model => model.storeId)
    <div class="editor-label" style='background-color:@(Model.id == theIdOfTheQuestion ? "blue" : "")'>
        <h3>What condition was your Item in when you received it? (1 - Very Poor, 2 - Standard, 3 - Good , 4 - Excellent)</h3>
    </div>
 <input type="submit" value="Create" class="button">

  [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Create(StoreQuestions storequestions)
    {
        if (ModelState.IsValid)
        {
            db.StoreQuestions.Add(storequestions);
            db.SaveChanges();
            return RedirectToAction("Details", "Questions", new { id = storequestions.QuestionsId });
        }

        return View(storequestions);
    }

您可以用@foreach 包裹&lt;div class="editor-label".. 以生成问题,并从中获得theIdOfTheQuestion

【讨论】:

  • 我知道它是什么但不知道如何处理它,因为我仍在改进前端开发,但是你建议将所有编辑器标签设置为蓝色背景,但我想要的是根据完成问卷的客户来改变背景
  • @cazlouise 我没有完整的代码,你需要提供更多信息,你可以使用后端语言和ajax请求来做着色条件。
猜你喜欢
  • 1970-01-01
  • 2017-09-21
  • 2011-02-06
  • 1970-01-01
  • 1970-01-01
  • 2015-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多