如何防止在pageload事件上继续添加动态文本框的值 [英] How to prevent keep adding values of dynamic textbox on pageload event

查看:68
本文介绍了如何防止在pageload事件上继续添加动态文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js>< / script>

< script type =text / javascript>

$(function(){



var email = eval('<%= valueEmail%>');

var name = eval('<%= Values%>');

if (email!= null){

var html =;

$(电子邮件).each(function(){

var div = $(

);

div.html(GetDynamicTextBox(name,email));

$(#TextBoxContainer)。append(div) ;



});

}

$(#btnAdd)。bind(click ,function(){

var div = $(

);

div.html(GetDynamicTextBox());

$(#TextBoxContainer)。append(div);

返回false;

});

$(body)。on(click,。remove,function(){

$(this).closest(div)。remove();

});

});

函数GetDynamicTextBox (valuename,valueemail){

return'< input name =ContactNametype =textvalue ='+ valuename +'/> '+'<输入名称=ContactEmailtype =textvalue ='+ valueemail +'/> '+

'< input type =buttonvalue =删除class =删除/>

}

< / script>



我有什么尝试过:



我正在尝试在动态文本框中添加值。当我添加多个文本框并在其中插入值时,在页面上重新加载第一个文本框值复制到下一个并循环继续。在每个页面加载时,值被复制到下一个文本框。我必须做什么来防止it.pl轻松帮助

解决方案

(function(){



var email = eval('<%= valueEmail%>');

var name = eval('<%= Values%>');

if( email!= null){

var html =;


(email).each(function(){

var div =


);

div.html(GetDynamicTextBox(name,email));

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {

var email = eval('<%=valueEmail%>');
var name = eval('<%=Values%>');
if (email != null) {
var html = "";
$(email).each(function () {
var div = $("

");
div.html(GetDynamicTextBox(name,email));
$("#TextBoxContainer").append(div);

});
}
$("#btnAdd").bind("click", function () {
var div = $("

");
div.html(GetDynamicTextBox(""));
$("#TextBoxContainer").append(div);
return false;
});
$("body").on("click", ".remove", function () {
$(this).closest("div").remove();
});
});
function GetDynamicTextBox(valuename,valueemail) {
return '<input name = "ContactName" type="text" value = "' + valuename + '" /> ' + '<input name = "ContactEmail" type="text" value = "' + valueemail + '" /> ' +
'<input type="button" value="Remove" class="remove" />'
}
</script>

What I have tried:

I am trying to add values in my dynamic textboxes.when i add more than 1 textboxes and insert values into them,on page reload the 1st textbox value copied to next one and cycle continues.on every page load the values gets copied to next textbox.what i have to do to prevent it.please help

解决方案

(function () {

var email = eval('<%=valueEmail%>');
var name = eval('<%=Values%>');
if (email != null) {
var html = "";


(email).each(function () {
var div =


("

");
div.html(GetDynamicTextBox(name,email));


这篇关于如何防止在pageload事件上继续添加动态文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆