Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
prgname="Select, Option and Button Example" If WinExist(prgname) Then WinClose(prgname) ;******* :example ;******* url=strcat("about:blank") Browser = objectopen("InternetExplorer.Application") Browser.left = 200 Browser.top = 200 Browser.width = 300 Browser.height = 300 Browser.TheaterMode = @False Browser.Resizable = @False Browser.addressbar = @False Browser.statusbar = @False Browser.menubar = @False Browser.toolbar = @False Browser.visible = @true browser.navigate(url) browserDoc = Browser.Document all = browserdoc.all iTimeOut = @False iTimeStop = GetTickCount() + 20000 While ((browser.Busy || (browser.ReadyState!=4)) && !iTimeOut) iTimeOut = ((iTimeStop - GetTickCount()) / 1000) < 1) TimeDelay(1) EndWhile If iTimeOut Then ObjectClose(browser) Drop(browser) Return (0) EndIf WinActivate(url) WInTitle(url,prgname) WInTitle(prgname,prgname) tmp=StrCat("<html><title>%prgname%</title></head><style>") tmp=StrCat(tmp,".aqua{font: 10px verdana; font-weight: none;color: #00BFBF;}") tmp=StrCat(tmp,".Red{font: 10px verdana; font-weight: none; color: red;}") tmp=StrCat(tmp,".Green{font: 10px verdana; font-weight: none; color: Green;}") tmp=StrCat(tmp,".Blue{font: 10px verdana; font-weight: none; color: blue;}") tmp=StrCat(tmp,".DarkPurple{font: 10px verdana; font-weight: none; Color: #75079E}") tmp=StrCat(tmp,".Purple{font: 10px verdana; font-weight: none;Color: #AD04CE}") tmp=StrCat(tmp,".box{FONT-WEIGHT: None; FONT-SIZE: 9pt; BACKGROUND:#F6Faf1; width: 100; CURSOR: hand;}") tmp=StrCat(tmp,".box2{FONT-WEIGHT: None; FONT-SIZE: 8pt; BACKGROUND:#F6Faf1; width: 125; CURSOR: hand;}") tmp=StrCat(tmp,".box1 {padding: 1;border-width: 1px;border-color: blue;border-style: solid;font-family: Tahoma, Verdana, sans-serif; CURSOR: hand;") tmp=StrCat(tmp,"font-size: 10px;font-weight: NONE;text-align: justify;color: C63CB5;width=125;background-color: white;align:center;}") tmp=StrCat(tmp,".btn{border-style: outset; border-color: lightsteelblue; border-width: 2; background-color: #D5DCEF; text-decoration: NONE; width: 105px; text-align: center; font: bold 7pt Verdana; color: blue; margin-bottom: 3px;}") tmp=StrCat(tmp,".btnover{border-style:outset; border-color:lightsteelblue; border-width: 2; background-color: #B5D7FF; text-decoration: NONE; width: 105px; text-align: center; font: bold 7pt Verdana; cursor: hand;color:darkblue;margin-bottom: 3px;}") tmp=StrCat(tmp,".msg{background-color:#E7EFFA;border-top-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-color:darkblue;") tmp=StrCat(tmp,"border-style:solid;border-width:1;font-family:Tahoma,Verdana,sans-serif;font-size:12px;font-weight:none;text-align:center;color:darkblue;width:100%%;height:70px;}") tmp=StrCat(tmp,"</style><body id=body scroll=no name=body value=Body>") tmp=StrCat(tmp,"<select size=5 name=SlectBox align=left><option name='Option 1' value='Option 1'>Option 1</option><option name='Option 2' value='Option 2'>Option 2</option>") tmp=StrCat(tmp,"<option name='Option 3' value='Option 3'>Option 3</option><option name='Option 4' value='Option 4'>Option 4</option><option name='Option 5' value='Option 5'>Option 5</option></select><center>") tmp=StrCat(tmp,"<div id=div1 name=div1 value='Div Tag 1'><input valign=top align=top type=text name='AddNewOption' value='Add New Option'><br><cemter>Check to Add") tmp=StrCat(tmp,"<input valign=top align=top type=checkbox name='CheckBox'></div><br>") tmp=StrCat(tmp,"<div id=div2 name=div2 value='Div Tag 2'><center>Delete Selected Option<br>No <input valign=top align=top type=radio name='RadioButton1' checked>") tmp=StrCat(tmp,"Yes <input valign=top align=top type=radio name='RadioButton2'></center></div></center><br><br><p align=center>") tmp=StrCat(tmp,"<input align=top type=button name='ClickMe' value='ClickMe'>") tmp=StrCat(tmp,"<input type=hidden name=button value=Exit></p>") tmp=StrCat(tmp,"<p name=msgwindow align=center id=msgwindow><br>This will show how to manipulate<br>Select Boxes, Options, Inputs,<br>CSS Class Names etc.... Enjoy!</p>") tmp=StrCat(tmp,"</body></html>") browserdoc.writeln(tmp) classes="Red|Green|Blue|DarkPurple|Purple" While 1 TimeDelay(.1) If !WinExist(prgname) Then Break ErrorMode(@Off) act = BrowserDoc.activeElement ;Get the currently Active Element Id If act==0 Then Break ErrorMode(@On) name = act.name ;Get the Name for the Active Element value = act.value ;Get the Value for the Active Element If value=="HTML" || value=="Body" Then Continue If name=="SlectBox" && value<>"" Then TimeDelay(.2) ;Give the Browser time to catch up! Need Help With This One! selbox=all.SlectBox ;Get the Select Box Name If selbox==-1 Then Continue slected=selbox.SelectedIndex ;Get the Selected Option Id z=all.RadioButton2 ;Get the Radio Button Id chk=z.checked ;Control Status (-1=Checked, 0=UnChecked) If chk=="-1" Then selbox.Remove(slected) ;Remove the Option from the Select Box value="%value% <b>Removed</b>" Endif ObjectClose(z) ObjectClose(selbox) Endif If name=="AddNewOption" Then x=all.CheckBox ;Get the Check Box Id x.checked=@False ;Set Control Status to Off Endif If name=="CheckBox" Then TimeDelay(.1) ;Give the Browser time to catch up! Need Help With This One! chk=act.checked ;Control Status (-1=Checked, 0=UnChecked) If chk=="-1" Then val=all.AddNewOption ;Get the Id of the Input Text Box x=val.value ;Get the Information from the Input Text Box val.value="Add New Option" ;ReSet the Information in the Input Text Box If x<>"Add New Option" NewOption=BrowserDoc.createElement("Option") ;Create a <Option> Element NewOption.text=x ;Set the <Option> Element text NewOption.value=x ;Set the <Option> Element value NewOption.classname="Aqua" ;Set the <Option> Element CSS Class NewOption.Selected=@False ;Set the <Option> Element Selected val=all.SlectBox ;Get the Select Box Id val.add(NewOption, 0) ;Add the Option to the Select box, '0' is the Location z=all.CheckBox ;Get the Check Box Name z.checked=@False ;Set Control Status to Off value="%x% <b>Added!</b>" name="SlectBox" ObjectClose(NewOption) ObjectClose(z) Else value="checked" Endif ObjectClose(val) Else value="unchecked" Endif Endif ;Note that this is the hard way! Simply set the Both ;Names the same and Values, on and off If name=="RadioButton1" || name=="RadioButton2" Then If value=="on" && name=="RadioButton1" Then x=all.RadioButton2 ;Get the Radio Name x.checked=@False ;Set Control Status to Off Endif If value=="on" && name=="RadioButton2" Then x=all.RadioButton1 ;Get the Radio Name x.checked=@False ;Set Control Status to Off Endif ObjectClose(x) Endif ObjectClose(act) If value=='ClickMe' Then x=BrowserDoc.getElementById("body") ;Get the <body> tag ID, not the name x.bgcolor="#f0f4f8" ;Set the Background Color for the Document boxID=all.SlectBox ;Get the Id for the Select Box boxID.classname="box" ;Set the Class for the Select Box ObjectClose(x) x = boxID.options ;Now lets get all the Options in the Select y = x.length ;Find out how many Options there are For i = 0 To y-1 class=ItemExtract(i+1, classes, "|") z = x.Options(i) ;Get a Option Id from the Select z.className=class ;Set the CSS Class for the Option val=z.value ;Get the value for the Option ;Display(2, prgname, "Apply CCS Class %class% to %val%") Next ObjectClose(z) ObjectClose(x) ObjectClose(boxID) x=all.button ;Get the Exit Button ID, next line overwrites ;the Button with a new one. x.outerHtml="<INPUT align=left class='btn' onMouseOver=this.className='btnover'; onMouseOut=this.className='btn'; TYPE=Button name=exit VALUE='Exit'>" x=all.ClickMe ;Get the 'Click Me' Button ID, next line overwrites ;the Button with a new one. x.outerHtml="<INPUT align=left class='btn' onMouseOver=this.className='btnover'; onMouseOut=this.className='btn'; TYPE=Hidden name=clickme VALUE='Click Me'>" ObjectClose(x) x=BrowserDoc.getElementById("div1") ;Get the <body> tag ID, not the name x.classname='box1' ;Set the Class Name for the <DIV> Tag ObjectClose(x) x=BrowserDoc.getElementById("div2") ;Get the <body> tag ID, not the name x.classname='box1' ;Set the Class Name for the <DIV> Tag ObjectClose(x) x=BrowserDoc.getElementById("msgwindow") ;Get the <body> tag ID, not the name x.classname='msg' ;Set the Class Name for the <DIV> Tag ObjectClose(x) x=all.AddNewOption x.classname='box2' ObjectClose(x) Endif If value=="Exit" Then Break If value<>"Body" Then x=BrowserDoc.getElementById("body") ;Get the <body> Tag ID, not the name x.SetActive ;Set the Body to the Active Element ObjectClose(x) putmsg="<br><b>Information</b><br>Selection: %name%<br>Value: %value%" Endif If IsDefined(putmsg) && name<>'ClickMe' Then x=BrowserDoc.getElementById("msgwindow") ;Get the <P> Tag ID, not the name x.innerHtml=putmsg ;Replace <P> Tag contents with a new message Drop(putmsg) ObjectClose(x) Endif TimeDelay(.1) EndWhile ObjectClose(all) ObjectClose(browserdoc) ObjectClose(browser) If WinExist(prgname) Then WinClose(prgname) Display(3, prgname, "Thats it") Return
Article ID: W16135
File Created: 2004:03:30:15:42:58
Last Updated: 2004:03:30:15:42:58