There are times when you want to use the client database on a Web page, but in order to be compatible with the version of the browser does not support XML technology, so here is a number of JS DML functions I want interested friends to discuss
function Trform ()
{
this. Trrc=new Array ();
this. Qrc=new Array ();//Result
this.currentrc=1;//current record pointer
this.lastrc=0;//Final Record
this. Number of rclength=arguments.length;//fields
this. Trrc[0]=new Array ();//Field name
for (i=0;i<this. rclength;i++) this. Trrc[0][i]=arguments[i];
THIS.ADDRC=ADDRC; Add a record
this.showrc=showrc;//Print current record
this.showprevious=showprevious;
This.shownext=shownext;
This.preload=preload; Pre-loaded Image
this.item2index=item2index;//The index of the field name to the array
This.showthis=showthis;
this. Isright=isright;
This.seek=seek;
}
function ADDRC ()
{
this. Trrc[++this.lastrc]=new Array ();
for (i=0;i<this. rclength;i++) this. Trrc[this.lastrc][i]=arguments[i];
return true;
}
function SHOWRC () {
for (rc=0;rc<this. qrc[0].length;rc++)
{
Theel=eval (this. QRC[0][RC]);
if (this. Qrc[0][rc].indexof ("image") ==-1) {
Theel.innertext=this. QRC[THIS.CURRENTRC][RC]
}
else{
Theel.src=this. QRC[THIS.CURRENTRC][RC];
}
}
return true;
}
function Shownext () {
This.seek ("All", "all")
if (++THIS.CURRENTRC>THIS.LASTRC) this.currentrc=this.lastrc;
THIS.SHOWRC ();
}
function Showthis () {
This.seek ("All", "all")
THIS.SHOWRC ();
}
function showprevious () {
This.seek ("All", "all");
if (--this.currentrc==0) this.currentrc=1;
THIS.SHOWRC ();
}
function preload () {
if confirm (' You need to load the picture into memory first, this will improve the smoothness of the browsing. If your network is slow, it is recommended not to load ', ' light and Shade ') {
status= ' picture loading ';
var imageindex=new Array ();
var n=0;
for (i=0;i<this. rclength;i++) {
if (this. Trrc[0][i].indexof ("image")!=-1) imageindex[n++]=i;
}
for (i=1;i<=this.lastrc;i++) {
for (var II in imageindex) {
var preimage=new Image ();
Preimage.src=this. TRRC[I][II];
status+= '. '
}
}
}
status= ';
return true;
}
function Item2index (item)
{
Val=-1
for (i=0;i<this. rclength;i++)
if (this. Trrc[0][i]==item) val=i;
return Val;
}
function Isright (rc,item,oper,exp)
{
Id=this.item2index (item);
Ends=false;
if (eval ("this. Trrc[rc][id] "+oper+" exp)) Ends=true;
return ends;
}
function Seek (EXP1,ITEM1)
{
var getexp=exp1.split ("@");
this. Qrc=new Array ();
var n=0;
var showitems=new Array ();
if (item1== ' all ") for (i=0;i<this. trrc[0].length;i++) Showitems[i]=this. Trrc[0][i];
else{
for (i=1;i<arguments.length;i++)
Showitems[n++]=arguments[i];
}
this. Qrc[0]=new Array ();
for (m=0;m<showitems.length;m++)
{
this. QRC[0][M]=SHOWITEMS[M];
}
for (m=0;m<showitems.length;m++)
{
Showitems[m]=this.item2index (showitems[m]);
}
temp=1;
if (getexp[0]== ' all ') {
for (k=1;k<=this.lastrc;k++)
{
this. Qrc[temp++]=new Array ();
for (i=0;i<showitems.length;i++)
{
this. Qrc[temp-1][i]=this. Trrc[k][showitems[i]];
}
}
}
Else
{
for (k=1;k<=this.lastrc;k++)
{
if (this. Isright (k,getexp[0],getexp[1],getexp[2])
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.