2016-11-10 65 views
0

我已經構建了一個允許客戶完成問卷調查的系統。爲了完成問卷,用戶必須輸入他們的唯一號碼,該號碼通過存儲過程使用不同數據庫中的數據。如何在用戶點擊按鈕時突出顯示提交的單元格

無論如何,我想要做的是當客戶完成他們的調查問卷,並點擊創建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); 
} 
+0

是否要點擊提交按鈕後突出顯示'editor-label' div? – Dabbas

+0

是的,我想要它發生 – cazlouise

回答

0

從來沒有測試的代碼,但:

<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); 
    } 

,你可以換<div class="editor-label"..@foreach產生的問題,並從中你得到的theIdOfTheQuestion

+0

我知道它是什麼,但不知道如何處理它,但我仍然在改善前端開發,但是你建議將所有的編輯標籤設置爲背景的藍色,但我想要的是基於完成調查問卷的客戶變更的背景 – cazlouise

+0

@cazlouise我沒有完整的代碼,您需要提供更多信息,您可以使用後端語言和ajax請求。 – Dabbas

+0

我用mvc c#方法更新了代碼 – cazlouise

相關問題