[jawsscripts] Re: The GetListOfFormFields function annd Delimiters

  • From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Thu, 24 Sep 2009 00:33:31 -0700

Nothing too bad, just a tune up and some hardware removal.

If there is no type attribute set, it's safe to assume that it is a text 
field. There should not be any default maxlength however if none is stated, 
though there may be a visible size default, but I'm not sure what this is if 
so.

If the input is type=image, then this would indicate the same lement type as 
type=button. The only difference is that type=image allows the displaying of 
an image instead of the default type=button display.

Hope this helps,
Bryan
----- Original Message ----- 
From: "Donald Marang" <donald.marang@xxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Wednesday, September 23, 2009 12:13 AM
Subject: [jawsscripts] Re: The GetListOfFormFields function annd Delimiters


> Thanks Brian,
>
> Hope you are feeling better!  I hope the surgery was something they were
> fixing and things are better now.  I have had more surgeries than I can
> count.  Many were not intended to 'fix' things.
>
> Does that if a form field is not specified as a particular type, that it 
> is
> a "text" edit field by default?  Is it given a default size and Max length
> as well?  On a similar  note, if the INPUT element is specified as type =
> "image", can it be anything other than a class = "actionbutton" element? 
> It
> is true on these badly written mobile  pages, but can I generalize that
> statement?
>
> Don Marang
>
>
> ----- Original Message ----- 
> From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Wednesday, September 23, 2009 2:26 AM
> Subject: [jawsscripts] Re: The GetListOfFormFields function annd 
> Delimiters
>
>
>> Hi, sorry for not getting back sooner, I recently had surgery, so have
>> been
>> out of commission.
>>
>> The short answer is that not using a type attribute within an input
>> element
>> is bad coding.
>>
>> Since you are scripting someone elses page though, and only some of the
>> edit
>> fields don't contain a type attribute, then you could check for the
>> following using the o object as mentioned before...
>>
>> if o.type == "text" || o.type == "" then
>> ; then o is an edit field
>> endif
>>
>> hope this helps.
>> Bryan
>>
>> ----- Original Message ----- 
>> From: "Donald Marang" <donald.marang@xxxxxxxxx>
>> To: <jawsscripts@xxxxxxxxxxxxx>
>> Sent: Friday, September 18, 2009 4:32 PM
>> Subject: [jawsscripts] Re: The GetListOfFormFields function annd
>> Delimiters
>>
>>
>>> Thanks Brian,
>>>
>>> I ended up using your method in a function that gathers all of the
>>> information I was looking for at one time.  I now use this loop starting
>>> at
>>> the last element and working backwards.  While in the loop, I count the
>>> buttons, and password / edit fields on the page. It passes back the Edit
>>> Field count, the  name of the first edit field, the count of buttons, 
>>> and
>>> returns the object pointer of the first button as the return value.
>>>
>>> I could not figure out how to identify an Edit field.  The Edit fields
>>> sometimes only have a name attribute.  Currently the function only
>>> identifies the username and search edit fields by name!  Not a
>>> generic,portable solution.  Does anyone know a better way to identify an
>>> Edit field? Would there be an attribute that would always be null in a
>>> form,
>>> but all other control types in the form     would return something?
>>>
>>> Perhaps I should just pass back the object pointer of the first Edit
>>> field
>>> as well and return all information as parameters by reference to make it
>>> more generic.  That way it might be more useful in other cases.  As it
>>> is,
>>> I
>>> call this function 3 times in this application.  I will paste the
>>> function
>>> below in case anyone is interested.  I welcome all comments so that I 
>>> can
>>> eventually learn how to script right.
>>> Object Function FieldInfo (int ByRef iFields, string ByRef sFirstEdit,
>>> int
>>> ByRef iButtons)
>>> Var
>>> Object dom,
>>> Object array,
>>> Object o,
>>> Int l,
>>> Int i,
>>> Object oEdit,
>>> Object oButton,
>>> String sName
>>> let dom = IEGetCurrentDocument()
>>> let array = dom.getElementsByTagName("input")
>>> Let l = array.length
>>> let i = l
>>> Let iFields = 0
>>> Let iButtons = 0
>>> SayMessage (OT_DEBUG, "length = " + IntToString (l))
>>> while i >= 0
>>> let o = array(i)
>>> if o.type == "password" then
>>>  SayMessage (OT_DEBUG, "password field found!  i = " + IntToString (i))
>>>  Let iFields = iFields + 1
>>>  Let oEdit = o
>>>  Let sFirstEdit = o.name
>>> ElIf o.class == "actionbutton" then
>>>  SayMessage (OT_DEBUG, "Action button found!  i = " + IntToString (i))
>>>  Let sName = o.value
>>>  SayMessage (OT_DEBUG, "value = " + sName)
>>>  Let iButtons = iButtons + 1
>>>  Let oButton = o
>>> ElIf o.type == "image" then
>>>  SayMessage (OT_DEBUG, "Button Image found!  i = " + IntToString (i))
>>>  Let sName = o.value
>>>  SayMessage (OT_DEBUG, "value = " + sName)
>>>  Let iButtons = iButtons + 1
>>>  Let oButton = o
>>> ElIf o.name == "userName" then
>>>  SayMessage (OT_DEBUG, "Username field found!  i = " + IntToString (i))
>>>  Let iFields = iFields + 1
>>>  Let oEdit = o
>>>  Let sFirstEdit = o.name
>>> ElIf o.name == "testInput" then
>>>  SayMessage (OT_DEBUG, "Search field found!  i = " + IntToString (i))
>>>  Let iFields = iFields + 1
>>>  Let oEdit = o
>>>  Let sFirstEdit = o.name
>>> endif
>>> Let i = i - 1
>>> EndWhile
>>> SayMessage (OT_DEBUG, "Edit field count = " + IntToString (iFields))
>>> SayMessage (OT_DEBUG, "First Edit field = " + sFirstEdit)
>>> SayMessage (OT_DEBUG, "Button count = " + IntToString (iButtons))
>>> Let sName = oButton.value
>>> SayMessage (OT_DEBUG, "Button value = " + sName)
>>> Return oButton
>>> EndFunction
>>> Don Marang
>>>
>>> ----- Original Message ----- 
>>> From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
>>> To: <jawsscripts@xxxxxxxxxxxxx>
>>> Sent: Tuesday, September 15, 2009 7:17 PM
>>> Subject: [jawsscripts] Re: The GetListOfFormFields function annd
>>> Delimiters
>>>
>>>
>>>> You could do something like the following to loop through all relevant
>>>> password form fields...
>>>>
>>>> var object dom, object array, object o, int i
>>>> let dom = IEGetCurrentDocument()
>>>> let array = dom.getElementsByTagName("input")
>>>> let i = 0
>>>> while(i < array.length)
>>>> let o = array(i)
>>>> if o.type == "password" then
>>>>
>>>> ; here is each instance of a password field within the o object.
>>>>
>>>> endif
>>>> let i = i + 1
>>>> endWhile
>>>>
>>>> ----- Original Message ----- 
>>>> From: "Donald Marang" <donald.marang@xxxxxxxxx>
>>>> To: <jawsscripts@xxxxxxxxxxxxx>
>>>> Sent: Tuesday, September 15, 2009 2:58 PM
>>>> Subject: [jawsscripts] The GetListOfFormFields function annd Delimiters
>>>>
>>>>
>>>>>I have been attempting to determine the number of Edit fields on a web
>>>>>page.  I have tried to pull that information from the DOM, but I am not
>>>>>grasping how to create a collection of edit / password fields.  As a
>>>>>backup, I attempted to use the GetListOfFormFields function.  I can use
>>>>>this function and then pass the returned string to the
>>>>> DlgSelectItemInList  function without any problems.  The
>>>>> DlgSelectItemInList  function will display the list showing and
>>>>> separating
>>>>> the segments properly.  However, the GetListOfFormFields function has 
>>>>> a
>>>>> delimeter as the first parameter, it does not use the delimeter
>>>>> specified!
>>>>> Therefore, I can not use StringSegmentCount to determine how many
>>>>> segments
>>>>> are in the list.  I wrote my own MyStringSegnentCount before I noticed
>>>>> that the GetListOfFormFields is at fault instead and does not use the
>>>>> delimiter as the documentation suggests.  Does anyone know how the
>>>>>
>>>>> DlgSelectItemInList  function determines how to split up the segments?
>>>>> Is
>>>>> there a error in my logic or use in the test example below?  Can 
>>>>> anyone
>>>>> suggest a robust method to obtain the number of edit / password fields
>>>>> visible on a web page?
>>>>>
>>>>>
>>>>> Here is a test function demonstrating the improper use of delimiters
>>>>> returned in the GetListOfFormFields:
>>>>> Script SegmentTest ()
>>>>>
>>>>> Var
>>>>>
>>>>> String sTestString,
>>>>>
>>>>> String sDelimiter,
>>>>>
>>>>> Int iSegments
>>>>>
>>>>> Let sDelimiter = "|"
>>>>>
>>>>> Let sTestString = "UserID/ email: Edit|password Edit| line 3 \tEdit"
>>>>>
>>>>> Let sTestString = GetListOfFormFields (sDelimiter , WT_EDIT)
>>>>>
>>>>> ; InputBox ("Enter new string: ", "Here is the full string!",
>>>>> sTestString)
>>>>>
>>>>> Let iSegments = StringSegmentCount (sTestString, sDelimiter)
>>>>>
>>>>> SayInteger (iSegments)
>>>>>
>>>>> EndScript
>>>>>
>>>>>
>>>>> Don Marang
>>>>>
>>>>>
>>>>> __________
>>>>> Visit and contribute to The JAWS Script Repository
>>>>> http://jawsscripts.com
>>>>>
>>>>> View the list's information and change your settings at
>>>>> //www.freelists.org/list/jawsscripts
>>>>>
>>>>
>>>> __________
>>>> Visit and contribute to The JAWS Script Repository
>>>> http://jawsscripts.com
>>>>
>>>> View the list's information and change your settings at
>>>> //www.freelists.org/list/jawsscripts
>>>>
>>>
>>> __________
>>> Visit and contribute to The JAWS Script Repository 
>>> http://jawsscripts.com
>>>
>>> View the list's information and change your settings at
>>> //www.freelists.org/list/jawsscripts
>>>
>>
>> __________
>> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>>
>> View the list's information and change your settings at
>> //www.freelists.org/list/jawsscripts
>>
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> //www.freelists.org/list/jawsscripts
> 

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: