I also found out the following:

var x=document.getElementsByName('textMARS');
alert(x.length);

The above code prints out "1", so I know that the element is being
found.  However:

x.value="1234567';

does not work.


On Jun 10, 2:25 pm, Toddintr <[email protected]> wrote:
> Thank you for your replies, much appreciated.
>
> I installed DOM Inspector which allowed me to look deep into the
> page.  I found the location of the input field I am interested in.
> But it's offset 20 levels in from the root HTML tag:
>
> #document -> HTML -> FRAMESET -> FRAME (2nd in the list) -> #document -> HTML 
> -> FRAMESET -> FRAME (name: account) -> #document -> HTML ->
>
> BODY -> DIV -> FORM -> TABLE -> TBODY -> TR (3rd in the list) -> TD ->
> TABLE -> TBODY -> TR -> TD -> INPUT (field)
>
> I also installed the XPath add-on, and that shows the above node as:
>
> /html/bo...@id='docBody']/d...@id='main']/form/table/tbody/tr[3]/td/
> table/tbody/tr[1]/td[2]/i
>
> Given the above, I am somewhat at a loss to generate the corresponding
> object instance through which I can set the field value.  I did try
> specifying the frame ids (both methods) but the text is not making its
> way into the field.
>
> I view this as a great learning opportunity so again, your guidance
> will be much appreciated.
>
> I would also like to know how to debug the script, even if by placing
> alert() calls.  For example, what would be good things to print in the
> alert() call?
>
> THANK YOU.
>
> -Todd
>
> On Jun 10, 4:30 am, Kwah <[email protected]> wrote:
>
> > Todd:
>
> > > <input type="text" maxlength="9" class="field" name="textMARS">
>
> > > The field is deep inside the page: nested inside a frame, then inside
> > > a form, and inside a cell in a table.
>
> > Jim:
>
> > > It's probably because 'textMARS' is not the id of the element but the
> > > name. Check out getElementsByName.
>
> > Jim is correct.
>
> > Also, if the field is within an iframe/frame then there's a chance
> > that you may not be able to get to it as easily as
> > document.getElementsByName() because IIRC document refers to the 'top'
> > document and the documents (frames) within this are defined separately
> > as contentDocument.
>
> > I strongly suggest doing some research of your own (I've not tested
> > this *at all*) but I think that this would be a good starting point to
> > doing what you seek to do:
>
> > // select the iframe element using your preferred method
> > // var iframe = document.getElementById("idOfTheFrame");
> > // var iframe = document.getElementsByTagName("frame")[0];
>
> > //(now that you have the first frame, either get the next nested frame
> > [[iframe.contentDocument.getElementsByTagName("frame")]] or seek out
> > the text field that you need)
>
> > // Select the Customer ID field
> > var customerIdField = iframe.contentDocument.getElementById('textMARS');
>
> > // Set the field's value
> > // NOTE: this is setting / storing login credentials in plaintext in
> > the script is *BAD*
> > // ((Also the same reasoning that many banks and secure sites eg Paypal use 
> > the
> > // autocomplete="off" attribute to prevent your browser from saving
> > login credentials))
>
> > customerIdField.value = '0123456789';
>
> > On 10/06/2010, John5342 <[email protected]> wrote:
>
> > > On Thu, Jun 10, 2010 at 01:21, Toddintr <[email protected]> wrote:
> > >> Thank you Kwah and Jim.  I inspected the page using Firebug and here's
> > >> the element for the customer id field:
>
> > >> <input type="text" maxlength="9" class="field" name="textMARS">
>
> > >> The field is deep inside the page: nested inside a frame, then inside
> > >> a form, and inside a cell in a table.
>
> > >> In my user script I have:
>
> > >>        document.getElementById('textMARS').focus();
> > >>        document.getElementById('textMARS').value = "1234567";
>
> > >> Unfortunately, I could not get it to work.  I am able to print a
> > >> "hello world" message from the script so I know it is being invoked.
> > >> Could it be that I need to fully qualify the element because it's so
> > >> deep inside the page?
>
> > > It's probably because 'textMARS' is not the id of the element but the
> > > name. Check out getElementsByName. More details here:
> > >http://www.w3schools.com/jsref/dom_obj_document.asp
>
> > > --
> > > There are 10 kinds of people in the world: Those who understand binary
> > > and those who don't...
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "greasemonkey-users" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/greasemonkey-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to