为什么数据未插入动态文本框中 [英] Why data is not inserted in dynamic textbox
问题描述
嗨我在html页面中有一个html和jsp页面通过动态文本框输入值,在jsp中我尝试进入但是当我尝试点击提交时没有发生任何事情都无法理解我在哪里坚持
我尝试过:
我的HTML代码:
< html>
< head>
< title> TODO提供标题< / title>
< meta charset = UTF-8>
< meta name =viewportcontent =width = device-width,initial-scale = 1.0>
< / head>
< body>
< form action =EmployeeVendorValidation.jspmethod =post>
< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js>< /脚本>
< script type =text / javascript>
function selectres(z){
var selection = z.val();
if(selection =='2'){
z.next( '输入')显示();
} else {
z.next('input')。hide();
}
}
$(function(){
$(#btnAdd)。bind(bind click,function(){
AddControl();
});
$( #btnGet)。bind(click,function(){
var values =;
$(input [name = DynamicTextBox1])。 (function(){
values + = $(this).val()+\ n;
});
var values =;
$(input [name = DynamicTextBox2])。each(function(){
values + = $(this).val( )+\ n;
});
警报(值);
}) ;
$(body)。on(click,。remove,function(){
$(this ).closest(div)。remove();
});
});
函数GetDynamicTextBox1(value){
return'Project:<输入名称=DynamicTextBox1id =ingr_projecttype =textvalue ='+ value +'required />& nbsp& nbsp& nbsp'+
'标题:< ;输入名称=DynamicTextBox2id =ingr_headertype =textvalue ='+ value +'required />& nbsp& nbsp& nbsp'+
'部门: < input name =DynamicTextBox3id =ingr_departmenttype =textvalue ='+ value +'required />& nbsp;& nbsp;& nbsp'+
'说明<输入名称=DynamicTextBox4id =ingr_descriptiontype =textvalue ='+ value +'required />& nbsp;& nbsp;& nbsp'+
'< input name =DynamicTextBox2style =display:noneid =res_nametype =textvalue ='+ value +'required />& nbsp'+ '< input type =buttonvalue =删除class =删除/>'
}
函数选择(z){
var selection = z.val();
if(selection =='2'){
z.next('输入')表示();
} else {
z.next('input')。hide();
}
}
函数AddControl(){
var div = $(< div /> ;);
div.append(GetDynamicTextBox1(''));
$(#TextBoxContainer)。append(div);
}
< / script>
< input id =btnAddtype =buttonvalue =Add/>< br>< br>
< div id =TextBoxContainer >
< / div>
< br>< br>
< input type =hiddenname =txtemployeeidvalue =employee_id>
< input type =submitname =btnSubmitvalue =提交/>< br>< br>
< / form>
< / body>
< / html>
(function(){
(#btnAdd)。bind(click,function(){
AddControl();
});
(#btnGet)。bind(click,function(){
var values = ;
Hi i have one html and jsp page in html page im putting value by dynamic text box and in jsp i tried to enter but when im try to click submit nothing has happen not able to understand where im stucking
What I have tried:
my html code:
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="EmployeeVendorValidation.jsp" method="post">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function selectres(z){
var selection=z.val();
if(selection == '2'){
z.next('input').show();
}else{
z.next('input').hide();
}
}
$(function() {
$("#btnAdd").bind("click", function() {
AddControl();
});
$("#btnGet").bind("click", function() {
var values = "";
$("input[name=DynamicTextBox1]").each(function() {
values += $(this).val() + "\n";
});
var values = "";
$("input[name=DynamicTextBox2]").each(function() {
values += $(this).val() + "\n";
});
alert(values);
});
$("body").on("click", ".remove", function() {
$(this).closest("div").remove();
});
});
function GetDynamicTextBox1(value) {
return 'Project:<input name = "DynamicTextBox1" id="ingr_project" type="text" value = "' + value + '" required/>   ' +
'Header:<input name = "DynamicTextBox2" id="ingr_header" type="text" value = "' + value + '"required/>   '+
'Department:<input name = "DynamicTextBox3" id="ingr_department" type="text" value = "' + value + '"required/>  '+
'Description<input name = "DynamicTextBox4" id="ingr_description" type="text" value = "' + value + '" required/>  '+
'<input name = "DynamicTextBox2" style="display:none" id="res_name" type="text" value = "' + value + '" required/> '+ '<input type="button" value="Remove" class="remove" />'
}
function selectres(z){
var selection=z.val();
if(selection == '2'){
z.next('input').show();
}else{
z.next('input').hide();
}
}
function AddControl() {
var div = $("<div />");
div.append(GetDynamicTextBox1(''));
$("#TextBoxContainer").append(div);
}
</script>
<input id="btnAdd" type="button" value="Add" /><br><br>
<div id="TextBoxContainer">
</div>
<br><br>
<input type="hidden" name="txtemployeeid" value="employee_id">
<input type="submit" name="btnSubmit" value="Submit" /><br><br>
</form>
</body>
</html>解决方案(function() {
("#btnAdd").bind("click", function() {
AddControl();
});
("#btnGet").bind("click", function() {
var values = "";
这篇关于为什么数据未插入动态文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!