/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Ajax extract form details

in the past i used an ajax script to extract data from a Div tag on another page

i am trying to do the same with form values
ive tried

[CODE]myRequest.responseText.mail.token.value;
myRequest.responseText.document.mail.token.value;

var div = document.createElement(‘div’);
div.innerHTML = myRequest.responseText;
var val = div.mail.token.value;[/CODE]

the form’s ID is mail, the input box i am trying to fetch is called token

any help is gladly appreciated
thanks

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyJan 22.2009 — These two are just messed up -- because responseText is just a string (not a rendered document):
[CODE]myRequest.responseText.mail.token.value;
myRequest.responseText.document.mail.token.value;[/CODE]

This is close, but no cigar:
[CODE]var div = document.createElement('div');
div.innerHTML = myRequest.responseText;
var val = div.mail.token.value;[/CODE]

Provided the div is in a FORM or the responseText contains an entire FORM in an HTML string, then this will work (all things being equal):
[CODE]var div = document.createElement('div');
div.innerHTML = myRequest.responseText;
var val = document.forms['mail'].elements['token'].value;[/CODE]
Copy linkTweet thisAlerts:
@PaPPyauthorJan 23.2009 — in error console i get

document.forms.mail is undefined
Copy linkTweet thisAlerts:
@MrNobodyJan 23.2009 — Then "mail" is not the name of your form.
Copy linkTweet thisAlerts:
@PaPPyauthorJan 23.2009 — crap i forgot i reworded things for on here

thank you, the form had an ID not a name, so i had to adjust it to what numbered form

thanks again
×

Success!

Help @PaPPy 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.18,
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,
)...