Paste a section of jquery on the JS object and array operation: Delete and change the code to check.
Copy Code code as follows:
var worklist = new Array ();//Array Object
The following are the entities that you define
function Workex (depart, title, BeginTime, Endtime) {
This. SId = 0;
This. Id =-(worklist.length+1);
This. Departmentname = Depart;
This. title = title;
This. BeginTime = BeginTime;
This. Endtime = Endtime;
This. Description = "";
This. Enable = 0;
return this;
}
function Deletework (GUID) {
worklist = $.grep (worklist, function (val, key) {
Return Val. Id!= GUID;
});
Showwork ();
}
function Showwork () {
var html = "";
$.each (worklist, Function (key, Val) {
HTML = html + "<span class=\" add_work_unit\ ">" + val. Departmentname + ":" + val. Title
+ ", Appointment time:" + Getjsdate (val. BeginTime) + "to" + Getjsdate (val. Endtime) + "<a href=\" #\ "onclick= ' Deletework (\" "+ val.) Id + "\") ' >x</a></span> ';
});
$ ("#tdWorkList"). HTML (HTML);
}
function Addwork () {
if (Checkisnull ("workaddress", "Work address cannot be blank")
&& checkisnull ("Worklevel", "Duty cannot be blank")
&& checkisnull ("Workbegin", "work start date cannot be empty")
&& checkisnull ("Workleave", "work end date cannot be blank")
)
{
var isOK = true;
$.each (worklist, Function (key, Val) {
if (Val. Departmentname = = $ ("#workaddress"). Val ()
&& val. Title = = $ ("#worklevel"). Val ()
&& val. BeginTime = = $ ("#WorkBegin"). Val ()
&& val. Endtime = = $ ("#WorkLeave"). Val ()
)
{
Alert ("has the same working experience. "); isok= false;
}
});
if (isOK) {
var onework = new Workex ($ ("#workaddress"). Val (), $ ("#worklevel"). Val (),
$ ("#WorkBegin"). Val (), $ ("#WorkLeave"). Val ())
Worklist.push (onework);
<span class= "Add_work_unit" > Lotte District, Sichuan Province, xxx pharmaceutical factory <a href= "#" >x</a></span>
Showwork ();
}
}
}