tijian_tieying/web/dccdc/Views/Infection/QuestionnaireAdd.cshtml

92 lines
3.6 KiB
Plaintext
Raw Normal View History

2025-02-20 12:14:39 +08:00
@{
ViewBag.Title = "QuestionnaireAdd";
}
<div id="checkQuestionnaireAdd">
<form id="editform">
<input id="id" type="hidden" name="id" value="0" />
<table class="t1" style="width:100%">
<tr style="display:none"><td class="rtd"><input id="user_id" class="l-text" name="user_id" style="width:220px" type="text" />user_id</td></tr>
<tr>
<td class="ltd" width="100px"><input id="code" class="l-text" name="code" type="hidden" />测试1:</td>
<td class="rtd"><input id="answer_One" class="l-text" name="answer_One" style="width:270px" type="text" /></td>
</tr>
<tr>
<td class="ltd" width="100px"><input id="code" class="l-text" name="code" type="hidden" />测试2:</td>
<td class="rtd" id="answer_Two">
<input id="radio1" type="radio" value="1" name="gender" />A
<input id="radio2" type="radio" value="2" name="gender" />B
</td>
</tr>
<tr>
<td class="ltd" width="100px"><input id="code" class="l-text" name="code" type="hidden" />测试3:</td>
<td class="rtd" id="answer_Three">
<input id="checkbox1" type="checkbox" name="vehicle" value="1" />A
<input id="checkbox2" type="checkbox" name="vehicle" value="2" />B
<input id="checkbox3" type="checkbox" name="vehicle" value="3" />C
<input id="checkbox4" type="checkbox" name="vehicle" value="4" />D
</td>
</tr>
<tr>
<td class="ltd" width="100px">录音上传:</td>
<td>
<input type="file" name="file" id="file" />
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" id="submitid" value="提交" class="l-button" onclick="sub()" />
</div>
</td>
</tr>
</table>
</form>
</div>
@section scripts{
<script type="text/javascript">
var addstr = document.URL;
var num = addstr.indexOf("?")
addstr = addstr.substr(num + 1);
$('#user_id').val(addstr);
function sub() {
var form = document.getElementById('editform'),
formData = new FormData(form);
var answer_Two;
var radio = document.getElementsByName("gender");
for (i = 0; i < radio.length; i++) {
if (radio[i].checked) {
answer_Two = radio[i].value;
}
}
var answer_Three = "";
var checkbox = document.getElementsByName("vehicle");
for (var i = 0; i < checkbox.length; i++) {
if (checkbox[i].checked) {
answer_Three += checkbox[i].value;
}
}
formData.append("answer_Two", answer_Two);
formData.append("answer_Three", answer_Three);
$.ajax({
url: "questionnaireAddData",
type: "post",
data: formData,
processData: false,
contentType: false,
success: function (res) {
if (res) {
alert("上传成功!");
}
console.log(res);
},
error: function (err) {
alert("网络连接失败,稍后重试", err);
}
});
}
</script>
}