469,603 Members | 2,075 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

Login, fill in forms, logout

Can I do the following with Javascript?

My state has a web site that can be used for online filing for
unemployment benefits. Every week I have to go to the site and fill in
a form, checking off the same boxes each time. I'd like to automate
this.

I need to load the URL for the login page into the browser, fill in my
username and password, and submit the form. From that page I need to
follow a link to file for benefits. There I need to fill in the form by
checking a few boxes and submit the form. This brings up another form
where I have to confirm the entries. Then finally I can select the
Logout link.

How would I go about automating that with Javascript? I don't need
someone to write the whole thing, just provide the basic processes. I
had a similar question a few weeks ago, when I was trying to create a
bookmarklet to open my web banking page and prefill the account number,
but I was never able to solve it (I'm making do with two bookmarks -- a
regular one to open the page, and a bookmarklet to fill in the account#
field once the page is loaded). This makes me think that my plan for
the unemployment page won't work either, but there's no harm in asking.

--
Barry Margolin, ba****@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Jul 20 '05 #1
4 5212
Barry Margolin <ba****@alum.mit.edu> writes:

[fill in form]
How would I go about automating that with Javascript? I don't need
someone to write the whole thing, just provide the basic processes. I
had a similar question a few weeks ago, when I was trying to create a
bookmarklet to open my web banking page and prefill the account number,
but I was never able to solve it


Bookmarklets should do it. You should remember the size limit on
bookmarklets in IE if that is your browser (250 characters IIRC).

Example (make one line and change names to use):

javascript:var f=document.forms[0],v="value";f.name[v]="My name";
f.account[v]="My account";f.sometingElse.checked=true;
f.someSelect.seletedIndex=4;f.submit():

Using "[v]" instead of ".value" saves three characters each time
it is used, and cost 10 to declare, so you need to use it more than
three times for the shorthand to pay off.
If you need to use "selectedIndex" or "checked" more than once or
twice, make it a variable too, in the same way as v="value" . It's
all about saving space :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote:
Barry Margolin <ba****@alum.mit.edu> writes:

[fill in form]
How would I go about automating that with Javascript? I don't need
someone to write the whole thing, just provide the basic processes. I
had a similar question a few weeks ago, when I was trying to create a
bookmarklet to open my web banking page and prefill the account number,
but I was never able to solve it

Bookmarklets should do it. You should remember the size limit on
bookmarklets in IE if that is your browser (250 characters IIRC).

Example (make one line and change names to use):

javascript:var f=document.forms[0],v="value";f.name[v]="My name";
f.account[v]="My account";f.sometingElse.checked=true;
f.someSelect.seletedIndex=4;f.submit():

Using "[v]" instead of ".value" saves three characters each time
it is used, and cost 10 to declare, so you need to use it more than
three times for the shorthand to pay off.
If you need to use "selectedIndex" or "checked" more than once or
twice, make it a variable too, in the same way as v="value" . It's
all about saving space :)


IF that doesn't work, Visual Basic can do it, or you can use this program:

http://www.roboform.com/

Jul 20 '05 #3
In article <8y**********@hotpop.com>,
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote:
Barry Margolin <ba****@alum.mit.edu> writes:

[fill in form]
How would I go about automating that with Javascript? I don't need
someone to write the whole thing, just provide the basic processes. I
had a similar question a few weeks ago, when I was trying to create a
bookmarklet to open my web banking page and prefill the account number,
but I was never able to solve it
Bookmarklets should do it. You should remember the size limit on
bookmarklets in IE if that is your browser (250 characters IIRC).


I'm using Safari on Mac OS X 10.3.2 (so no Visual Basic, although I've
been wondering if AppleScript might work).
Example (make one line and change names to use):

javascript:var f=document.forms[0],v="value";f.name[v]="My name";
f.account[v]="My account";f.sometingElse.checked=true;
f.someSelect.seletedIndex=4;f.submit():

Using "[v]" instead of ".value" saves three characters each time
it is used, and cost 10 to declare, so you need to use it more than
three times for the shorthand to pay off.
If you need to use "selectedIndex" or "checked" more than once or
twice, make it a variable too, in the same way as v="value" . It's
all about saving space :)


Where in that bookmarklet does it go from page to page to page? After
submitting the login form, it needs to do the equivalent of clicking on
a link to get to the "file for benefits" form.

When I tried to write my previous bookmarklet, I tried assigning to
window.location to get it to load a new page, and then assign to the
form fields. The problem was that page loading happens asynchronously,
so the field assignments were being done *before* the page was actually
loaded (I could tell this was happening because if I ran the Javascript
while I was already looking at the form page, I could see it briefly
fill in the fields before reloading with an unfilled version of the
form).

What I need is a way to assign to window.location and then wait for the
browser to finish loading the page.

BTW, my ideal goal would be to do this all unattended. I'd like to set
up a cron job, so that every week this just happens automatically,
without me needing to click on anything at all. Since I'm using OS X,
which is Unix, if anyone has Unix CLI-based suggestions I'd be open to
that as well.

--
Barry Margolin, ba****@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Jul 20 '05 #4
Barry Margolin <ba****@alum.mit.edu> writes:
Where in that bookmarklet does it go from page to page to page?
It doesn't. You would then click another bookmarklet for the next page.
If youare using IE, you could look into a HTA-file, which is a HTML
file with extra permissions. Put the page you want into an iframe
and monitor it from the HTA-page.
BTW, my ideal goal would be to do this all unattended.
In that case, I wouldn't use a browser at all. Perhaps Perl, if you
know how :)
I'd like to set up a cron job, so that every week this just happens
automatically, without me needing to click on anything at all.


Definitly not a browser :)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by koolyio | last post: by
2 posts views Thread by Brian Henry | last post: by
1 post views Thread by MichaelR | last post: by
2 posts views Thread by Shakun | last post: by
1 post views Thread by Jakob Lithner | last post: by
3 posts views Thread by =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post: by
10 posts views Thread by DavidPr | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.