隐藏字段中的 JavaScript 值操作
我想要从隐藏字段中删除由“^”分割的一组特定值 我将价值放在隐藏字段中。现在我想要删除特定的值集,即
隐藏字段值 = 1|1|1|1^2|2|2|2^3|3|3|3
DROP DOWN=
索引|价值|文本
0 | 1 |1
1 | 2 |2
2 | 3 |3
想要删除 = ^2|2|2|2,下拉值为 2;
这是我的代码,显示了如何将值放入隐藏字段中
function putinactions()
{
var hiddenfield = document.getElementById("hdfActions");
var ActList= document.getElementById("Actionlist");
var attdt= document.getElementById("txtAttOn");
var depen= document.getElementById("ddlDepend");
var tattby= document.getElementById("txtAttendedBy");
var dattby= document.getElementById("ddlAttendedBy");
var dpriority= document.getElementById("ddlPriority");
var taction= document.getElementById("txtAction");
var dstatus= document.getElementById("ddlStatus");
var tacdt= document.getElementById("txtACDt");
if(depen.value==9)
{
tattby.value = "0";
}
if(depen.value!=9)
{
dattby.value = "0";
}
if(hiddenfield.value=="")
{
hiddenfield.value=
attdt.value+"|"+
depen.value+"|"+
tattby.value+"|"+
dattby.value+"|"+
dpriority.value+"|"+
taction.value+"|"+
dstatus.value+"|"+
tacdt.value;
}
else
{
hiddenfield.value=hiddenfield.value+"^"+
attdt.value+"|"+
depen.value+"|"+
tattby.value+"|"+
dattby.value+"|"+
dpriority.value+"|"+
taction.value+"|"+
dstatus.value+"|"+
tacdt.value;
}
var optn = document.createElement("OPTION");
optn.text=attdt.value+"~~"+taction.value.substring(0,20)+"...";
optn.value=taction.value;
ActList.options.add(optn);
attdt.value="";
depen.value="";
taction.value="";
tacdt.value="";
}
I want a particular set of values splitted by "^" deleted from a hidden field
I am putting value in hidden fields. Now I want particular values set deleted, i.e.
HIDDEN FIELD VALUE = 1|1|1|1^2|2|2|2^3|3|3|3
DROP DOWN=
INDEX |VALUE | TEXT
0 | 1 |1
1 | 2 |2
2 | 3 |3
WANT TO DELETE = ^2|2|2|2 WITH DROPDOWN VALUE 2;
Here is my code showing how I put values in the hidden field
function putinactions()
{
var hiddenfield = document.getElementById("hdfActions");
var ActList= document.getElementById("Actionlist");
var attdt= document.getElementById("txtAttOn");
var depen= document.getElementById("ddlDepend");
var tattby= document.getElementById("txtAttendedBy");
var dattby= document.getElementById("ddlAttendedBy");
var dpriority= document.getElementById("ddlPriority");
var taction= document.getElementById("txtAction");
var dstatus= document.getElementById("ddlStatus");
var tacdt= document.getElementById("txtACDt");
if(depen.value==9)
{
tattby.value = "0";
}
if(depen.value!=9)
{
dattby.value = "0";
}
if(hiddenfield.value=="")
{
hiddenfield.value=
attdt.value+"|"+
depen.value+"|"+
tattby.value+"|"+
dattby.value+"|"+
dpriority.value+"|"+
taction.value+"|"+
dstatus.value+"|"+
tacdt.value;
}
else
{
hiddenfield.value=hiddenfield.value+"^"+
attdt.value+"|"+
depen.value+"|"+
tattby.value+"|"+
dattby.value+"|"+
dpriority.value+"|"+
taction.value+"|"+
dstatus.value+"|"+
tacdt.value;
}
var optn = document.createElement("OPTION");
optn.text=attdt.value+"~~"+taction.value.substring(0,20)+"...";
optn.value=taction.value;
ActList.options.add(optn);
attdt.value="";
depen.value="";
taction.value="";
tacdt.value="";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有兴趣删除 ^ 字符包围的值,您可以简单地使用正则表达式。
If you are interested in removing the values enclosed by ^ characters, you can simply use a regular expression.