Javascript Value Manipulation In Hidden Field
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 |3WANT 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+"|"+开发者_如何学Python
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="";
}
If you are interested in removing the values enclosed by ^ characters, you can simply use a regular expression.
精彩评论