/    Sign up×
Community /Pin to ProfileBookmark

Pulling data from returned page?

hey all,

I am trying to do something that is clearly out of my skill level! I am attempting to hit a page that has a form (the page is hosted by someone else), fill it out with premade values and submit the form with code, and then pull some data from the resulting HTML page. The first part of this works great, but I can not figure out how to get the data from the resulting page. The data on that page is taged with id values. My code for opening the window, filling out and submitting the form is the following:

<SCRIPT language=”JavaScript”>
function submitform(){return(“<body onload=’document.calc.submit()’><form action=’http://www.ssa.gov/cgi-bin/benefit6.cgi‘ method=’post’ name=’calc’ id=’calc’><input type=’hidden’ name=’dobmon’ id=’month’ size=’2′ maxlength=’2′ value=’12’><input type=’hidden’ name=’dobday’ id=’day’ size=’2′ maxlength=’2′ value=’1′><input type=’hidden’ name=’yob’ id=’year’ size=’4′ maxlength=’4′ value=’1975′><input type=’hidden’ name=’earnings’ id=’earnings’ size=’7′ maxlength=’7′ value=’40000′><input type=’hidden’ name=’lastYearEarn’ id=’lastyear’ size=’4′ maxlength=’4′ value=”><input type=’hidden’ name=’lastEarn’ id=’lastearnings’ size=’7′ maxlength=’7′ value=”><input type=’hidden’ name=’retiremonth’ id=’retiremonth’ size=’2′ maxlength=’2′ value=’12’><input type=’hidden’ name=’retireyear’ id=’retireyear’ size=’4′ maxlength=’4′ value=’2020′><input type=’hidden’ name=’dollars’ id=’constant’ value=’1′ checked=’checked’><input type=’hidden’ name=’dollars’ id=’nominal’ value=’0′><input type=’hidden’ name=’prgf’ value=’2′>”);
}
var newWin = open(“”, “win”, “width=900,height=900”);
var newDoc = newWin.document;
newDoc.open(“text/html”);
newDoc.write(submitform());
newDoc.close();
</script>

My thought was that I could simply use the newDoc object and getElementById to pull out the data I need, but it doesn’t seem to work. Any thoughts or suggestions?

Thanks in advance!
Pete

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @chiefmojo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...