在我的html表单中,我有一个增加html表单行的javascript功能。但不知何故,它在控制台日志中返回错误:
以下是错误消息: 未捕获的SyntaxError:意外的标记ILLEGAL
以下是我正在使用的js代码:
// First serializing
dynamic collection = new { stud = stud_datatable }; // The stud_datable is the list or data table
string jsonString = JsonConvert.SerializeObject(collection);
// Second Deserializing
dynamic StudList = JsonConvert.DeserializeObject(jsonString);
var stud = StudList.stud;
foreach (var detail in stud)
{
var Address = detail["stud_address"]; // Access Address data;
}
你能告诉我为什么它会出现在我的代码中吗?
更新: Html代码:
// add more email number
$(document).ready(function() {
var max_fields = 4; //maximum input boxes allowed
var wrapper = $("#emailWraper"); //Fields wrapper
var add_button = $("#addMoreEmail"); //Add button ID
var x = 1; //initlal text box count
$(add_button).click(function(e) { //on add input button click
e.preventDefault();
if (x < max_fields) { //max input box allowed
x++; //text box increment
<?php $sql = mysqli_query($link, 'SELECT * FROM contact_type'); ?>
$(wrapper).append("<tr id='deleteEmail'><td align='right' style='padding-right:10px;'><select name='phoneExt[]'><option value=''>--select--</option><?php while($result_ctype = mysqli_fetch_array($sql)){ $ctid = (int) $result_ctype['ctid']; $all_Contact_type = inputvalid($result_ctype['contact_type']); echo " < option value = $ctid > "; echo $all_Contact_type; echo '</option>';}?></select></td><td align='right'><input type='text' name='' class='small3' id='' placeholder='Value'/><a href='#' class='remove_field'> X</a></td></tr>"); //add input box*/
}
});
$(wrapper).on("click", ".remove_field", function(e) { //user click on remove text
e.preventDefault();
$("#deleteEmail").remove();
x--;
})
});