473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Populate form fields on a remote website

Hi there,

New to javascript. Question about populating a form on a webpage that I
do not control. I can see the field names and ids and currently have a
button that onsubmit opens the page in a new window that contains the
form I'd like to populate. Any tips on how to populate the form. We're
trying to make it easier for users to submit it... no bots as it has a
captcha.
Aug 19 '08 #1
4 3232
On Aug 19, 3:46 pm, brad <byte8b...@gmail.comwrote:
Hi there,

New to javascript. Question about populating a form on a webpage that I
do not control. I can see the field names and ids and currently have a
button that onsubmit opens the page in a new window that contains the
form I'd like to populate. Any tips on how to populate the form. We're
trying to make it easier for users to submit it... no bots as it has a
captcha.
See "cross-site scripting"...
Aug 19 '08 #2
On Aug 19, 9:46*am, brad <byte8b...@gmail.comwrote:
Hi there,

New to javascript. Question about populating a form on a webpage that I
do not control. I can see the field names and ids and currently have a
button that onsubmit opens the page in a new window that contains the
form I'd like to populate. Any tips on how to populate the form. We're
trying to make it easier for users to submit it... no bots as it has a
captcha.
Just grab a reference to the DOM element you're after and set the
'value' attributes.

Look into getElementsByName() and getElementById(). The first returns
an array (NodeSet actually) so if it is the only element with that
'name' in your document then you would have to say something like:

document.getElementsByName('someName')[0].value = "some value"

If you could get an element reference starting at the form, you could
iterate through the form using nextChild and/or nextSibling and set
all the values to what you like.

Oh, and one more thing I guess, since you are opening this up in a new
window, you must reference the correct document. If your script is in
the new window, you could just say "document.", but if you are doing
it from the parent window, use the reference returned when your create
the child window.

And if you're opening the document in a frame, you must also consider
this when trying to get a reference to an element. And everything may
fail anyway, depending on how forms loaded in a frame from another
domain are handled when submitted. I'm not sure to be honest with you.

http://developer.mozilla.org/en/docs...lement#Methods
http://developer.mozilla.org/en/docs/DOM:window.frames

slightly off topic since this can't be used by your users, but:
http://en.wikipedia.org/wiki/Greasemonkey
Good luck!
Aug 19 '08 #3
brad wrote:
New to javascript. Question about populating a form on a webpage that I
do not control.
Chances are that you cannot do this with client-side scripting alone because
of the Same Origin Policy. However, often documents containing forms can
take parameters per the URI's query part (after the `?') which would then
populate the form.

Simple example:

<http://groups.google.com/groups?as_q=%22Same+Origin+Policy%22&as_ugroup=com p.lang.javascript&scoring=d&filter=0>

See also <http://jibbering.com/faq/>.
HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 20 '08 #4
On Aug 20, 8:52*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
brad wrote:
New to javascript. Question about populating a form on a webpage that I
do not control.

Chances are that you cannot do this with client-side scripting alone because
of the Same Origin Policy. *However, often documents containing forms can
take parameters per the URI's query part (after the `?') which would then
populate the form.

Simple example:

<http://groups.google.com/groups?as_q=%22Same+Origin+Policy%22&as_ugro....>

See also <http://jibbering.com/faq/>.

HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
* -- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Right you are sir.

I did a little test, and apparently one cannot access the DOM of a
document loaded in a frame or iframe when the document originates from
another domain.

This is rather well known I suppose, but I had never really given the
problem any thought before. It makes perfect sense, however. I suppose
allowing this would be a big security problem.

But the security measures that stop this DOM access seem to be the
sole responsibility of the browser. Of course, I don't suppose there
would be any other way to handle it, since all of this stuff happens
client side. But I have given some thought about the various ways one
could break this, and I don't think it would be terribly difficult to
come up with a work around.

But what legitimate reasons would one have to do something like this?
Aug 22 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MicroMoth | last post by:
I know that this is probably a simple question, but I can't seem to find out how to populate the form fields I have with the results from my stored procedure, which I have stored in a datase. I...
7
by: ero | last post by:
Is it possible to input values into a web form from an external source like a client-side javascript? There is a web site that I'm viewing where I have to enter 5 values in the form. 4 of the...
15
by: terbolee | last post by:
I have two tables: Organisations & Invoices. I have a form called Invoices that is used to enter data into the invoices Table. When entering data, I'd like to be able to type into the field, and...
3
by: wparrott | last post by:
Hello everyone, I'm trying add a print button that opens a Word document and fills in form fields in the document based on the currently displayed record. The code works in a sample that I ran but...
1
by: chadpaynter | last post by:
A lot of the work I do in web development tends to be a set of web forms allowing a user to apply for a product or service which has usually resulted in me writing code behind to read the form...
2
by: dan07 | last post by:
Language used: Javascript Application using iFrame: Microsoft CRM 3.0 form Is there a generic way for an iFrame to send a variable to a remote website form? I need to be able to open up the...
1
by: ramel | last post by:
Hi all, I have a problem related to javascript , ajax and jsp. Please see this url http://xil.co.in/print_screen_2.JPG. I am working on this form. There are some buttons (like submit ,...
0
by: Robert Ingles | last post by:
Hello all; I am in the process of designing a customer gift order DB (for taking phone orders) in Access. I am including a lookup for the phone number in order to populate the customer information...
2
by: Horace Martin | last post by:
How do I populate multiple fields on a form by using a combo box. My combo box has 3 col. When I make a selection from my combo box all 3 fields should be filled in on my form. eg. Form Fields:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.