Page 1 of 1 1
Topic Options
#122420 - 2004-07-08 08:21 PM Capturing multiple selections in web form text box
Netsuper Offline
Getting the hang of it

Registered: 2001-05-17
Posts: 64
Loc: Edwards AFB, CA, US
Hey all,
I'm trying to capture multiple selections in an IE text box. I was using GetElementById but it only returns the first entry in the list of multiple selections. I then tried GetElementsByName which is supposed to return a string of values, but I don't get any data in the variable when I use that method.

Here's the code:

$OSystemsAffected = $doc.GetElementsByName("SystemsAffected")

$mSystemsAffected = $OSystemsAffected.value

Any ideas on what I'm doing wrong?
_________________________
Scott Hickerson Network Design Engineer

Top
#122421 - 2004-07-09 03:44 PM Re: Capturing multiple selections in web form text box
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
what is $doc ?
Is this the complete code ??













_________________________



Top
#122422 - 2004-07-12 04:50 PM Re: Capturing multiple selections in web form text box
Netsuper Offline
Getting the hang of it

Registered: 2001-05-17
Posts: 64
Loc: Edwards AFB, CA, US
Here's the code pertaining to the object creation, does this help?


$ie = createobject("internetexplorer.application")
if $ie = 0 exit endif
$ie.addressbar="0"
$ie.menubar="0"
$ie.toolbar="0"
$ie.statusbar="0"
$ie.resizable="true"
$ie.visible="true"
$ie.top="0"
$ie.left="0"
;$ie.fullscreen="1"
$ie.width="850"
$ie.height="850"
$ie.navigate("about:blank")
$doc=$ie.document
$do = $doc.Open
$doc.write($html + @crlf)
while $ie.busy<>0 and @error=0 Loop


thanks!
_________________________
Scott Hickerson Network Design Engineer

Top
#122423 - 2004-07-12 05:13 PM Re: Capturing multiple selections in web form text box
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Can you post the $html too ? Fully understand if its "sensitive".
Top
#122424 - 2004-07-12 05:41 PM Re: Capturing multiple selections in web form text box
Netsuper Offline
Getting the hang of it

Registered: 2001-05-17
Posts: 64
Loc: Edwards AFB, CA, US
The $html is loaded from an html file through WSHpipe into memory. here is a sample of html multiple selection dropdown box. can't post my code, but the file loads and all other variables are captured by GetElementbyID just fine. It's only this multiple select that returns only the first line of the selection.
_____________________________________
<select size="1" id="description" name="description" multiple>
<option value="selection1">selection1</option>
<option value="selection2">selection2</option>
<option value="selection3">selection3</option>
</select>
_____________________________________

Thanks!
_________________________
Scott Hickerson Network Design Engineer

Top
#122425 - 2004-07-12 08:08 PM Re: Capturing multiple selections in web form text box
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
here's how i would do it:

Code:

break on

$html = '<h3>Select some options and click OK</h3><br>
<select size="1" id="description" name="description" multiple>
<option value="selection1">selection1</option>
<option value="selection2">selection2</option>
<option value="selection3">selection3</option>
</select><br>
<button id="ok" name="0" onclick="ok.name=1">OK</button><br>
<h3>Selections:</h3><textarea id="listing" style="height:180">
'

$ie = createobject("internetexplorer.application")
if $ie = 0 exit endif
$ie.addressbar="0"
$ie.menubar="0"
$ie.toolbar="0"
$ie.statusbar="0"
$ie.resizable="true"
$ie.visible="true"
;$ie.top="0"
;$ie.left="0"
;$ie.fullscreen="1"
$ie.width="640"
$ie.height="480"
$ie.navigate("about:blank")
$doc=$ie.document
$do = $doc.Open
$doc.write($html + @crlf)
while $ie.busy<>0 and $ie.ReadyState <> 4 and @error=0 Loop

$OK = $doc.GetElementById("ok")

if $OK

$options = $doc.GetElementById("Description")
$output = $doc.GetElementById("listing")

while $ie.Visible

while not $OK.Name = 1 and $ie.Visible

sleep 0.500

loop

$output.value = ""

for each $option in $options

if $option.selected

$output.value = $output.value + $option.value + chr(10)

endif

next

$OK.Name = 0
$options.focus()

loop

endif

$ie.visible = 0
$ie.quit()

exit 0



-Shawn

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 671 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.081 seconds in which 0.033 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org