Dynamic button Builder (top)

Source: Internet
Author: User
Tags array
Very cool, everybody together to research and research!
}}checkbrowser ();//the Image Object
function Imageobject (name,offsrcpro,offsrc,onsrcpro,onsrc,width,height,alt,border,url,linktarget) {this. Name=name;this. Offsrcpro=offsrcpro;this. Offsrc=offsrc;this. Onsrcpro=onsrcpro;this. Onsrc=onsrc;this. Width=width;this. Height=height;this. Alt=alt;this. Border=border;this. Url=url;this. linktarget=linktarget;this.length=11;} function Headerselect (GRUT,GRUTV) {if (grut.options[0].selected) {grutv.value= "";} Else{for (Var y=0;y<grut.length;y++) {if (grut.options[y].selected) {grutv.value= ""; Grutv.value+=grut.options[y] . text;}}} Function performing Form Validation
function Checkme (Me) {with (me) {srcbox1.focus (); Srcbox1.blur (); Srcbox2.focus (); Srcbox2.blur (); if (urlbox.value== "http://" | | urlbox.value== "") {alert ("The connection URL is not set");
Urlbox.focus ();
return false;
}if (srcbox1.value== "") {alert ("Mouseout Picture not set");
Srcbox1.focus ();
return false;
}if (srcbox2.value== "") {
Alert ("MouseOver Picture not set");
Srcbox2.focus ();
return false;
}
if (namebox.value== "") {
Alert ("Picture not named");
Namebox.focus ();
return false;
}
return true;}
function Checkandshow () {
With (window.document.mouseOverForm.Images) {if (options.length!=0) {for (Var i=0;i<options.length;i++) {if ( options[i].selected) {with (Window.document.mouseOverForm) {urlbox.value=imagi[i]. URL; Targetbox.value=imagi[i]. LinkTarget; Headsrc1.value=imagi[i]. Offsrcpro; Headsrc2.value=imagi[i]. Onsrcpro; Srcbox1.value=imagi[i]. OFFSRC; Srcbox2.value=imagi[i]. ONSRC; Namebox.value=imagi[i]. Name; Borderbox.value=imagi[i]. Border
Altbox.value=imagi[i]. Alt; Widthbox.value=imagi[i]. Width; Heightbox.value=imagi[i]. Height;currentimage=i;if (headsrc1.value== "file:///")
Header1.options[1].selected=true;else if (headsrc1.value== "http://")
Header1.options[2].selected=true;else if (headsrc1.value== "")
Header1.options[0].selected=true;if (headsrc2.value== "file:///")
Header2.options[1].selected=true;else if (headsrc2.value== "http://")
Header2.options[2].selected=true;else if (headsrc2.value== "")
Header2.options[0].selected=true}}}}
}
}function InsertItem () {with (Window.document.mouseOverForm) {if (Checkme (Window.document.mouseOverForm)) {Imagi[no_ Of_images]=new Imageobject (Namebox.value,headsrc1.value,srcbox1.value,headsrc2.value,srcbox2.value, Widthbox.value,heightbox.value,altbox.value,borderbox.value,urlbox.value,targetbox.value); Images.length+=1;I Mages.options[images.length-1].text=imagi[no_of_images]. Name;++no_of_images; Cleanboxes (Window.document.mouseOverForm); Cleanboxes (Window.document.mouseOverForm);}} Clean Options[0] When page loaded
function clean () {abc=document.forms[0]. Images;if (imagi.length==0&&abc.length!=0) {for (Var loop=0;loop<abc.length;loop++)
Abc.options[loop]=null}} function Updateoption () {with (Window.document.mouseOverForm) {if (currentimage!=-1) {if confirm ("Sure you want to update this data?") {Imagi[currentimage]. Url=urlbox.value;imagi[currentimage]. Linktarget=targetbox.value;imagi[currentimage]. Name=namebox.value;imagi[currentimage]. Offsrcpro=headsrc1.value;imagi[currentimage]. Onsrcpro=headsrc2.value;imagi[currentimage]. Offsrc=srcbox1.value;imagi[currentimage]. Onsrc=srcbox2.value;imagi[currentimage]. Width=widthbox.value;imagi[currentimage]. Height=heightbox.value;imagi[currentimage]. Alt=altbox.value;imagi[currentimage]. Border=borderbox.value;images.options[currentimage].text=imagi[currentimage]. Name;alert ("Data has been updated!"); Cleanboxes (Window.document.mouseOverForm); Cleanboxes (window.document.mouseOverForm);} Else
Alert ("You have not selected any items!");} function Removeit () {if (document.mouseoverform.images.selectedindex<0)
Alert ("You have not selected any items!"); With (Document.mouseOverForm.Images) {for (Var t=0;t<length;t++) {if (options[t].selected) {if (Confirm ("Sure to remove picture?") {for (Var z=t;z<length-1;z++) {Imagi[z]. URL=IMAGI[Z+1]. URL;IMAGI[Z]. LINKTARGET=IMAGI[Z+1]. LINKTARGET;IMAGI[Z]. OFFSRCPRO=IMAGI[Z+1]. OFFSRCPRO;IMAGI[Z]. ONSRCPRO=IMAGI[Z+1]. ONSRCPRO;IMAGI[Z]. OFFSRC=IMAGI[Z+1]. OFFSRC;IMAGI[Z]. ONSRC=IMAGI[Z+1]. ONSRC;IMAGI[Z]. NAME=IMAGI[Z+1]. NAME;IMAGI[Z]. BORDER=IMAGI[Z+1]. BORDER;IMAGI[Z]. ALT=IMAGI[Z+1]. ALT;IMAGI[Z]. HEIGHT=IMAGI[Z+1]. HEIGHT;IMAGI[Z]. WIDTH=IMAGI[Z+1]. Width;}
Imagi.length-=1;--no_of_images;options[t]=null; Cleanboxes (Window.document.mouseOverForm);}}}}
function Debug () {var no=prompt ("Please enter the Object number for you want to Debug", ""); var second_argu= "imagi[" +no+ "]" sho W_props (IMAGI[NO],SECOND_ARGU);} For debugging usage
function Show_props (obj,obj_name) {var result= ""; for (var i in obj)
Result+=obj_name+ "." +i+ "=" +obj[i]+ "\ n"; alert (result);} Clean the options[0] when page loaded
function clean () {abc=document.mouseoverform.images;if (imagi.length==0&&abc.length!=0) {for var loop=0; loop<abc.length;loop++)
Abc.options[loop]=null}} Clean the value in the fields
function Cleanboxes (argv) {var x=0;//counter
while (x!=argv.length-1) {
if (argv.elements[x].type== "text") {argv.elements[x].value= "";} X++;ARGV. Urlbox.value= "http://"; argv. HEADER1.OPTIONS[0].SELECTED=TRUE;ARGV. HEADER2.OPTIONS[0].SELECTED=TRUE;ARGV. Headsrc1.focus (); argv. Headsrc1.blur (); argv. Headsrc1.value= ""; argv. Headsrc2.focus (); argv. Headsrc2.blur (); argv. Headsrc2.value= "";
Argv. Srcbox1.focus (); argv. Srcbox1.blur (); argv. Srcbox1.value= ""; argv. Srcbox2.focus (); argv. Srcbox2.blur (); argv. Srcbox2.value= "";
Argv. Urlbox.focus ();} Closedd=true;function popdrive (NO) {if (closedd) {box=no; first= ' Pop.focus ();} function make (na,no) {na. Drive.focus (); Na. Drive.blur (); if (Na. drive.value== "") {
Alert ("File not selected!"); Pop.focus ();} Else{if (no==1) {Document.mouseoverform.srcbox1.value=na. Drive.value;
Document.mouseoverform.header1.options[1].selected=true;document.mouseoverform.headsrc1.value= "file:///";} else if (no==2) {Document.mouseoverform.srcbox2.value=na. Drive.value;
Document.mouseoverform.header1.options[1].selected=true;document.mouseoverform.headsrc2.value= "file:///";} Pop.close (); window.closedd=true;}} Check the image Source,then change the protocol if needed
function Checkandchange (NO) {if (no==1) {srcbox=document.mouseoverform.srcbox1; Selection=document.mouseoverform.header1; PROTOCOLBOX=DOCUMENT.MOUSEOVERFORM.HEADSRC1;} else if (no==2) {srcbox=document.mouseoverform.srcbox2; Selection=document.mouseoverform.header2; PROTOCOLBOX=DOCUMENT.MOUSEOVERFORM.HEADSRC2;} var c=srcbox.value.indexof ("http://"); var d=srcbox.value.indexof ("file:///"); if (c>=0) {selection.options[2]. Selected=true; Protocolbox.value= "http://"; Stringo2=srcbox.value.substring (C+7); Srcbox.value=stringo2;} else if (d>=0) {selection.options[1].selected=true; Protocolbox.value= "file:///"; Stringo3=srcbox.value.substring (D+8); Srcbox.value=stringo3;} var find2=srcbox.value.indexof ("/")
if (SrcBox.value.indexOf (": \") >0| | SrcBox.value.indexOf ("|/") >0) {selection.options[1].selected=true; Protocolbox.value= "file:///"; var cr=srcbox.value.indexof (": \ \"); if (cr>=0) {Srcbox.value=stringinsert ( Srcbox.value, "|", CR); for (Var countit=cr;countit<srcbox.value.length;countit++) {var Athere=srcbox.value.charat (countit); if (athere== "\")
Srcbox.value=stringinsert (Srcbox.value, "/", countit);
}}}else if ((SrcBox.value.indexOf (". com") >0) | | (SrcBox.value.indexOf (". edu") >0) | | (SrcBox.value.indexOf (". org") >0) | | (SrcBox.value.indexOf (". NET") >0) | | (SrcBox.value.indexOf (". gov") >0) | | (SrcBox.value.indexOf (". Mil") >0) | | (SrcBox.value.indexOf (". arpa") >0) | | (SrcBox.value.indexOf (". int") >0) {selection.options[2].selected=true; Protocolbox.value= "http://";} else if (find2>0) {var yes=0;var c=0;var stringoo2=srcbox.value.substring (0,find2); for (Var a=0;a<3;a++) {
var b=stringoo2.indexof (".", c); if (b>0) {c=b+1;
yes++}} if (yes==3) {
Selection.options[2].selected=true; Protocolbox.value= "http://";}
Else{selection.options[0].selected=true; Protocolbox.value= "";} if (srcbox.value!= "") {var stringo=srcbox.value.touppercase (); if (Stringo.indexof). GIF ") <0&&stringo.indexof (". JPG ") <0&&stringo.indexof (". JPEG ") <0&&stringo.indexof (". PNG ") (<0) {alert (" apparently not set up the correct picture file:) "); Srcbox.focus ();}} function Stringinsert (initial,replace,position) {start=parseint (position); end=start+replace.length;newval= Initial.substring (0,start) +replace+initial.substring (end,initial.length); return newval;} function IsDigit (form) {for (Var x=0;x<form.value.length;x++) {var y=form.value.charat (x); var g=parseint (y); if (g >=0&&g<=9); Else{alert ("Illegal parameters!") "); Form.focus (); return false;}} return true;} function Insertbelow ()
{with (Window.document.mouseOverForm)
{if (images.selectedindex!=-1)
{for (Var g=0;g<imagi.length-1;g++)
{if (images.options[g].selected)
{var r=no_of_images;imagi[r]=new imageobject (imagi[r-1). NAME,IMAGI[R-1]. OFFSRCPRO,IMAGI[R-1]. OFFSRC,IMAGI[R-1]. ONSRCPRO,IMAGI[R-1]. ONSRC,IMAGI[R-1]. WIDTH,IMAGI[R-1]. HEIGHT,IMAGI[R-1]. ALT,IMAGI[R-1]. BORDER,IMAGI[R-1]. URL,IMAGI[R-1]. LinkTarget); for (Var p=imagi.length-2;p>g;p--)
{Imagi[p]. NAME=IMAGI[P-1]. NAME;IMAGI[P]. OFFSRCPRO=IMAGI[P-1]. OFFSRCPRO;IMAGI[P]. OFFSRC=IMAGI[P-1]. OFFSRC;IMAGI[P]. ONSRCPRO=IMAGI[P-1]. ONSRCPRO;IMAGI[P]. ONSRC=IMAGI[P-1]. ONSRC;IMAGI[P]. WIDTH=IMAGI[P-1]. WIDTH;IMAGI[P]. HEIGHT=IMAGI[P-1]. HEIGHT;IMAGI[P]. ALT=IMAGI[P-1]. ALT;IMAGI[P]. BORDER=IMAGI[P-1]. BORDER;IMAGI[P]. URL=IMAGI[P-1]. URL;IMAGI[P]. LINKTARGET=IMAGI[P-1]. LinkTarget;}
IMAGI[G+1]. URL=URLBOX.VALUE;IMAGI[G+1]. LINKTARGET=TARGETBOX.VALUE;IMAGI[G+1]. NAME=NAMEBOX.VALUE;IMAGI[G+1]. OFFSRCPRO=HEADSRC1.VALUE;IMAGI[G+1]. ONSRCPRO=HEADSRC2.VALUE;IMAGI[G+1]. OFFSRC=SRCBOX1.VALUE;IMAGI[G+1]. ONSRC=SRCBOX2.VALUE;IMAGI[G+1]. WIDTH=WIDTHBOX.VALUE;IMAGI[G+1]. HEIGHT=HEIGHTBOX.VALUE;IMAGI[G+1]. ALT=ALTBOX.VALUE;IMAGI[G+1]. border=borderbox.value;no_of_images++;




Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.