将HTML的值复选框发送到django视图

时间:2016-10-04 15:49:49

标签: python html django jenkins

我有以下HTML页面

<input type="checkbox" name="checks[]" value="1">REG_AGREED_SUITE01
  </label>
   <hr>
  <label class="checkbox">
  <input type="checkbox" name="checks[]" value="2">REG_AGREED_SUITE02
  </label>
   <hr>
  <label class="checkbox">
  <input type="checkbox" name="checks[]" value="3">REG_AGREED_SUITE03
  </label>

我有像这样的Django视图

cd1 = "<command>"
cd2 = "</command>"
test_runner_path = "Abc - C:\git_new\evo_automation\ tests\TestRunner"
test_runner_path2 = "Def - C:\git_new\evo_automation\ tests\TestRunner"
STB = "VMS_01"
TestSuite = "REG_AGREED_SUITE02"

现在我正在从视图中手动传递TestSuite值。但我想尝试,如果我从html页面选择复选框,它应该替换视图中的硬编码值并传递参数。我有什么方法可以做到吗?

1 个答案:

答案 0 :(得分:1)

使用Jquery和ajax请求将数据传递给视图:

   $("checkbox").change(function(){
        $.post("path/to/url",
        {
            checkBoxValue: $("#CheckboxID").val()
        }
    });
相关问题