#67586 - 2002-06-27 01:34 AM
Re: ComboBox Function is Working!!!
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
The $html is usually/can be passed into the iecreatewindow... Where you put it in, would overwrite the data passed into it.
If it were placed into the else statement a few lines down, that would be best.
The other functions are correct
code:
Function IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") while $ie.busy and $ie.readystate <> 4 and @error = 0 loop $ie.document.body.scroll = no if $html $ie.document.write('$html') else $ie.document.write('<html><head><title>$title</title></head><body>') endif $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $IECreateWindow = $ie $ie.Visible = 1 while setfocus("$title") <> 0 loop EndFunction
I'm gonna upload the new changes to my web page
|
|
Top
|
|
|
|
#67587 - 2002-06-27 01:52 AM
Re: ComboBox Function is Working!!!
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Rad, may a suggest this slightly modified version of your CreateWindow script. It disposes of all DHTML and retains attributes across F5 refreshes.
code:
Function IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") while $ie.busy and $ie.readystate <> 4 and @error = 0 loop if $html $ie.document.write('$html') else $ie.document.write('<html><head><title>$title</title> </head><body scroll=no bgcolor="threedface" border="1px solid #cccccc">') endif $IECreateWindow = $ie $ie.Visible = 1 while setfocus("$title") <> 0 loop EndFunction
|
|
Top
|
|
|
|
#67588 - 2002-06-27 02:22 AM
Re: ComboBox Function is Working!!!
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#67590 - 2002-06-27 02:25 AM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Rad,
I will take your suggestion and implement it. Just noticed when looking at the source that the html was not properly formatted.. When I did the formatting, it looks great!
I also know that IE is more forgiving when it comes to errors as I have seen this type of thing with ASP..
Kent
|
|
Top
|
|
|
|
#67591 - 2002-06-27 02:32 AM
Re: ComboBox Function is Working!!!
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#67593 - 2002-06-27 02:31 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Shawn, Rad & Kent, Thanks for all the help on this one. Sorry I kinda dropped off the radar yesterday. I had a very large network problem that demanded my time. I'm still putting out the brush fires and I'm exhausted! What can I do to help get this to the UDF lib? Thanks again! Did anyone get it to work? [ 27 June 2002, 14:55: Message edited by: Dana Eddy ]
|
|
Top
|
|
|
|
#67594 - 2002-06-27 04:56 PM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Dana,
Yes.. I got it to work under XP.. Here, lemme try under my NT System..
Here is the code with Rad's/Shawn's suggestions..
I have added in some stuff to look at using this for our login script..
It looks like NT does not like this - Maybe something to do with - CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3" ?? I also tried to install the ADSNT.EXE with no difference.
{Edit} I take this back.. I waited a few moments and there is a dropdown under NT. {Edit}
code:
BREAK ON
; Set initially to string
$elementarray=""
; -- Build Internet Explorer Window $window = IECreateWindow("@Domain - Logon Script",300,300,640,480)
$hour=val(substr(@time,1,2))
SELECT CASE $hour<12 $tod = 'Good Morning' CASE $hour<18 $tod = 'Good Afternoon' CASE 1 $tod = 'Good Evening' ENDSELECT
IEWrite($window,"hello","Arial","4","#00ff00") IEWrite($window,"$tod, @fullname") IEWrite($window,"You are logging in as @userid",,"2","#ff0000") IEWrite($window,"You are logging in to @wksta","Courier","5","#0000ff") IEWrite($window,"Welcome to the @Domain Domain")
; Enumerate hostnames in the domain
$cont = getobject("WinNT://" + @domain + ",domain") $cont.filter = "computer","" FOR EACH $machine IN $cont $obj = $machine.name $elementarray=$elementarray + ", "+$obj ; append to string, comma-delimed NEXT
; Morph the comma-delimed string into an array ... $elementarray = split($elementarray,",") ;; $rc=execute('$$ElementArray = split($$ElementArray,",")')
;******************
; Enumerate the array ...
; FOR EACH $element IN $elementarray ;Test to see array ; ? "Element=" $element ; NEXT
IEComboBox($window,"Domain List","Test IT",$element) ;pass array $b1=IEAddButton($window,"Button1",10,0,50,25) $b2=IEAddButton($window,"Button2",70,0,50,25) $b3=IEAddButton($window,"Button3",130,0,50,25)
?"pause..." GET$k
$window.quit $window = 0 EXIT 1
;****************** ; -- Functions used ;****************** Function IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") while $ie.busy and $ie.readystate <> 4 and @error = 0 loop if $html $ie.document.write('$html') else $ie.document.write('<html><head><title>$title</title> </head><body scroll=no bgcolor="threedface" border="1px solid #cccccc">') endif $IECreateWindow = $ie $ie.Visible = 1 while setfocus("$title") <> 0 loop EndFunction ;****************** FUNCTION IEWrite($window,$text, optional $font, optional $size, optional $color, optional $clear) IF NOT $font $font='Verdana, Helvetica, sans-serif' ENDIF IF NOT $size $size='3' ENDIF IF NOT $color $color='#000000' ENDIF IF NOT $bgcolor $bgcolor='#ffffff' ENDIF $html = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($html) WHILE $window.busy <> 0 AND @error = 0 LOOP ENDFUNCTION ;****************** FUNCTION IEComboBox($window,$title,$text,$element)
$html='<BR>$text<BR> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=24 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </object></body></html> ' $window.document.write('$html')
WHILE $window.busy <> 0 AND @error = 0 LOOP
$combobox = $ie.document.getelementbyid("combobox")
FOR EACH $element IN $elementarray $RC=$combobox.additem("$Element") NEXT
$combobox.value=$elementarray[0]
ENDFUNCTION ;****************** FUNCTION IEAddButton($window,$caption,$left,$top,$width,$height) DIM $button $button = $window.document.createelement("input") $button.type = "Button" $button.value = $caption $button.style.position = "Absolute" $button.style.pixeltop = $top $button.style.pixelleft = $left $button.style.pixelwidth = $width $button.style.pixelheight = $height $button = $window.document.body.appendchild($button) $ieaddbutton = $button ENDFUNCTION ;****************** FUNCTION IESetBackColor($window,$color) $window.document.body.bgcolor = $color ENDFUNCTION ;****************** FUNCTION IEInputBox($title, Optional $prompt, optional $ok, optional $cancel) DIM $click, $html, $window, $status, $click, $button, $box
IF NOT $prompt $prompt = "Please enter your password." ENDIF IF NOT $ok $ok = "OK" ENDIF IF NOT $cancel $cancel = "Cancel" ENDIF
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$window = IECreateWindow($title,100,100,300,130,$html) WHILE $window.busy AND $window.readystate <> 4 AND @error = 0 LOOP $window.document.getelementbyid("input").focus $status = $window.document.getelementbyid("status") $click = $window.document.getelementbyid("input") $button= 0 $box=0 WHILE @error = 0 AND $button = 0 $button=$status.value $box=$click.value SELECT CASE $button = "1" $ieinputbox = $box CASE $button = "2" $ieinputbox = "Cancel" ENDSELECT LOOP $window.quit $window="" ENDFUNCTION
HTH,
Kent [ 27 June 2002, 17:23: Message edited by: kdyer ]
|
|
Top
|
|
|
|
#67595 - 2002-06-27 05:44 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Shawn & gang, Help...I'm so close?? I have worked on the code and it's real close.. I believe the problem lies with one of two lines. code:
$Button.onclick = "frm.Submitted.value=1"
-or- code:
$BoxVal.selectedvalue
I can not get the buttons to function... Here is all of the code; code:
break on
$ElementArray="machine1","machine2","machine3","machine4","machine5","machine6","machine7","machine8","machine9"
$Window = IECreateWindow("A Simple ComboBox",300,300,640,480) IEWrite($Window,"Select from the list below...","Courier","5","#0000ff") IEComboBox($Window,"A Simple ComboBox","Your Selection",$ElementArray) ;pass array $b1=IEAddButton($Window,"Submit","Submit",1,2,220,80,75,30) $b2=IEAddButton($Window,"Cancel","Cancel",2,-1,310,80,75,30)
while $window.busy and $window.readystate <> 4 and @error = 0 loop $window.document.GetElementById("ComboBox").focus $SubmitClick = $window.document.GetElementById("Submit") $CancelClick = $window.document.GetElementById("Cancel") $BoxVal = $window.document.GetElementById("ComboBox") $button= 0 $box=0 while @error = 0 and frm.submitted.value <> 0 ? $SubmitClick.value ? $BoxVal.selectedvalue sleep (5) If Trim ("$SubmitClick.value") <> "Submit" $button= $SubmitClick.value $Box = $Boxval.selectedvalue Endif If Trim ("$CancelClick.value") <> "Cancel" $button=$CancelClick.value $Box ="Cancel" Endif loop
?"Return: " $box ?"pause..." get$k
$window.quit $window = 0 exit 1 ;&&&&&&&&&&&&&&&&&&&&&&& ; Function IEAddButton($Window,$Caption,$ID,$ClickVal,$TabIdx,$Left,$Top,$Width,$Height) dim $Button $Button = $Window.Document.CreateElement("input") $Button.Type = "Button" $Button.Value = "$caption" $Button.ID = $ID $Button.onclick = "frm.Submitted.value=1" $Button.Tabindex= "$TabIdx" $Button.Style.Position = "Absolute" $Button.Style.PixelTop = $Top $Button.Style.PixelLeft = $Left $Button.Style.PixelWidth = $Width $Button.Style.PixelHeight = $Height $Button = $Window.Document.Body.AppendChild($Button) $IEAddButton = $Button EndFunction
;***********************************************************************************************
Function IEComboBox($Window,$title,$text,$ElementArray)
$html='<HTML><HEAD><TITLE>$title</TITLE></HEAD><BODY><BR>$text<BR><form name=frm> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=26 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT> </form></BODY></HTML> ' $window.document.write('$html') WHILE $window.busy <> 0 AND @ERROR = 0 LOOP $combobox = $IE.document.GetElementById("combobox") for each $element in $ElementArray $=$combobox.additem("$Element") next $combobox.value=$ElementArray[0] EndFunction
;*********************************************************************************************** Function IECreateWindow($title,$left,$top,$width,$height, optional $html) $ie = createobject("internetexplorer.application") $ie.addressbar = 0 $ie.menubar = 0 $ie.toolbar = 0 $ie.statusbar = 0 $ie.top = $top $ie.left = $left $ie.width = $width $ie.height = $height $ie.navigate("about:blank") while $ie.busy and $ie.readystate <> 4 and @error = 0 loop $ie.document.body.scroll = no if $html $ie.document.write('$html') else $ie.document.write('<title>$title</title>') endif $ie.document.body.bgcolor = "threedface" $ie.document.body.border = "1px solid #cccccc" $IECreateWindow = $ie $ie.Visible = 1 while setfocus("$title") <> 0 loop EndFunction
Function IEWrite($Window,$text, optional $font, optional $size, optional $color, optional $Clear) if not $font $font='Verdana, Helvetica, sans-serif' endif if not $size $size='3' endif if not $color $color='#000000' endif if not $bgcolor $bgcolor='#ffffff' endif $HTML = '<font size="$size" FACE="$font" color="$color">$text<br></font>' $window.document.write($HTML) WHILE $window.busy <> 0 AND @ERROR = 0 LOOP EndFunction
Function IESetBackColor($Window,$Color) $Window.Document.Body.BGColor = $Color EndFunction
Function IEInputBox($title, Optional $prompt, optional $Ok, optional $Cancel) Dim $click, $html, $Window, $status, $click, $button, $box
If not $prompt $prompt = "Please enter your password." endif If not $ok $ok = "OK" endif If not $Cancel $cancel = "Cancel" endif
$html = ' <html><head><title>$title</title><style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no > <table align=center> <form name=frm> <tr> <td align=right>$prompt </td> <td colspan=2><input id=input value="" class=tbox></td> </tr> <tr> <td><input id=ok type=button value=" $ok " onclick="frm.status.value=1"> <input type=hidden id=status name=status value=0></td> <td align=right><input id=cancel type=button value=" $Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
$Window = IECreateWindow($title,100,100,300,130,$html) while $window.busy and $window.readystate <> 4 and @error = 0 loop $window.document.GetElementById("input").focus $status = $window.document.GetElementById("status") $click = $window.document.GetElementById("input") $button= 0 $box=0 while @error = 0 and $button = 0 $button=$status.value $box=$click.value select case $button = "1" $IEInputBox = $box case $button = "2" $IEInputBox = "Cancel" endselect loop $window.quit $window="" EndFunction
|
|
Top
|
|
|
|
#67596 - 2002-06-27 06:07 PM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Dana,
We need to go back and clean up some of the HTML Coding (I know picky.. picky...)
Current HTML Source..
code:
<title>A Simple ComboBox</title> <font size="5" FACE="Courier" color="#0000ff">Select from the list below...<br></font> <HTML><HEAD><TITLE>A Simple ComboBox</TITLE></HEAD> <BODY><BR>Your Selection<BR><form name=frm> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=26 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT> </form> </BODY></HTML>
The html should be cleaned up to be:
code:
<HTML><HEAD><TITLE>A Simple ComboBox</TITLE></HEAD> <BODY><font size="5" FACE="Courier" color="#0000ff">Select from the list below...<br></font> <BR>Your Selection<BR><form name=frm> <OBJECT ID="ComboBox" WIDTH=200 HEIGHT=26 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> </OBJECT> </form> </BODY></HTML>
So, if we look at a form properties in HTML..
code:
<form method="POST" NAME="Order" action="odrcnfrm.asp"> <input NAME="Order_FullName" SIZE="35"> <input TYPE="submit" VALUE="Submit Order"> <input TYPE="reset" VALUE="Reset Order Form"> </form>
I know this is a different methodology used too..
So, this should help get this rolling..
Kent [ 27 June 2002, 18:08: Message edited by: kdyer ]
|
|
Top
|
|
|
|
#67597 - 2002-06-27 06:19 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Kent, I took your source, bypassed the $ElementArray and manually filled the array. I then ran the program. The combobox does display but the buttons don't function . I can not get the selected value back to kix. Have you done so yet?
|
|
Top
|
|
|
|
#67598 - 2002-06-27 06:33 PM
Re: ComboBox Function is Working!!!
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Dana,
No.. I have not been able to get the submits to work..
One thing I would like to see is an input box (line) where a status could be input like "Mapping drive H:"... "Mapping drive R:"..
Kent
|
|
Top
|
|
|
|
#67599 - 2002-06-27 10:23 PM
Re: ComboBox Function is Working!!!
|
Anonymous
Anonymous
Unregistered
|
Shawn, Rad & Kent Check this out! It works! Have Fun & thanks for the help along the way. No gripes about long lines, please? {edit} I need to clean it up... I have some left over junk in it still (Beta Code) {/edit}
code:
; IEComboBox.kix ; Thursday, June 27, 2002 Dana Eddy ; It is compatable with Kix 4.xx tested in 4.02 break on ;SETCONSOLE("HIDE") $ElementArray="Please Select","DomainMachine1","DomainMachine2","DomainMachine3","DomainMachine4","DomainMachine5","DomainMachine6","DomainMachine7","DomainMachine8" $OK = HTMLComboBox("Your Selection...","Manage WorkStations","Enter","Cancel") EXIT
;*********************************************************** ;HTML Combo Box: ; SYNTAX: ; HTMLComboBox("HTML Message", OPTIONAL "Window Title", OPTIONAL "Button Text", OPTIONAL "Alt Button Text", OPTIONAL "Alt Button Return Value") ;;################################ FUNCTION HTMLComboBox($L_Prompt, OPTIONAL $L_Title, OPTIONAL $L_ButtonText, OPTIONAL $L_AltButtonText, OPTIONAL $L_AltButtonReturnValue) $timeout = 0 $SelectedVal = "Not Selected" IF $L_Title = "" $L_Title = "Question..." ENDIF IF $L_ButtonText = "" $L_ButtonText = "Submit" ENDIF IF $L_AltButtonReturnValue = "" $L_AltButtonReturnValue = -1 ENDIF $L_TextColor = "FFFF00" $L_BGColor = "000000"
$HTML = '<HTML>' + '<BODY scroll=no TEXT=' + $L_TextColor + ' BGCOLOR=' + $L_BGColor + '>' + '<TITLE>' + $L_Title + '</TITLE><B>' + $L_Prompt + '</B>' + '<form name=MyForm>' + '<BR>' + '<OBJECT ID="ComboBox" WIDTH=200 HEIGHT=26 CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"></OBJECT> '+ '<input id=Submitted name=Submitted type=hidden value=0>' + '<input id=Submit name=Submit type=button value=" ' + $L_ButtonText + ' "' + ' onclick="MyForm.Submitted.value=1" Tabindex="2">'
IF $L_AltButtonText <> "" $HTML = $HTML + '<input id=AltButton name=AltButton type=button value=" ' + $L_AltButtonText + ' "' + ' onclick="MyForm.Submitted.value=2" Tabindex="3">' ENDIF $Bottomtext = "Select Workstation - Then Click: </BR><H1>Enter Two Times</H1><BR>To start the Image Restore Process." + " Or Select CANCEL to End the Process." $HTML = $HTML + '<Center><BR>$Bottomtext</BR></Center></FORM>' $html = $html + '<TABLE ALIGN="Center" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"> <TR ALIGN="Center" VALIGN="middle"> <TH>Status</TH></tr> <TR ALIGN="Center" VALIGN="middle"> <TD><H1><input id=ReturnVal name=ReturnVal Size=25 MaxLength=25 value="$SelectedVal"></H1></TD></TR> </TABLE></BODY></HTML>'
$appIE = CREATEOBJECT("InternetExplorer.Application")
;Set IE Object Properties $appIE.top = 180 $appIE.left = 262 $appIE.height = 450 $appIE.width = 450 $appIE.addressbar = 0 $appIE.menubar = 0 $appIE.toolbar = 0 $appIE.statusbar = 0 $appIE.resizeable = 0 $appIE.FullScreen = 0 $appIE.Offline = False $appIE.navigate("about:blank") WHILE $appIE.busy <> 0 AND @ERROR = 0 LOOP
;Write the HTML code to the document $appIE.document.write($HTML) IEComboBox($AppIE,$ElementArray) ;pass array
WHILE $appIE.busy <> 0 AND @ERROR = 0 LOOP
;Make IE visible and set focus $appIE.visible = 1 $focus= SETFOCUS("about:blank - Microsoft Internet Explorer") $appIE.document.GetElementById("ComboBox").focus
DIM $L_LastBoxValue,$L_LastBoxValueCache WHILE $appIE.document.GetElementById("Submitted").value <> 2 IF $appIE.document.GetElementById("Submitted").value = 1 $L_LastBoxValue = $appIE.document.GetElementById("ComboBox").value If $L_LastBoxValue <> "Please Select" $L_LastBoxValueCache = $L_LastBoxValue $SelectedVal = "Processing " + $L_LastBoxValue $appIE.document.GetElementById("ReturnVal").value = $SelectedVal ;Place your commands here;;;;;;;;;;;;;;;;;; ? "You sellected: " + $SelectedVal sleep(2) ;only here to show it works ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $appIE.document.GetElementById("Submitted").value = 0 $combobox.value=$ElementArray[0] $SelectedVal = "Please Select" $appIE.document.GetElementById("ReturnVal").value = $SelectedVal ENDIF ENDIF LOOP $appIE.QUIT $appIE = "" ENDFUNCTION
;*********************************************************************************************** Function IEComboBox($Window,$ElementArray) WHILE $window.busy <> 0 AND @ERROR = 0 LOOP $combobox = $AppIE.document.GetElementById("combobox") for each $element in $ElementArray $=$combobox.additem("$Element") next $combobox.value=$ElementArray[0] EndFunction
[ 27 June 2002, 22:38: Message edited by: Dana Eddy ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|