Quantcast

Forums | MacLife

You are not logged in.

#1 2005-06-20 9:23 am

zakatak
Member
From: Kalamazoo
Registered: 2004-08-05
Posts: 565

JS Form Question

So here's my question:

Can JS manipulate forms on a page other than its own? Checking checkboxes or submitting a form, something like that.

I have tried

Code:

window.opener.forms.myForm.submit();

but that didn't seem to work well...

Offline

 

#2 2005-06-20 9:39 am

registered_user
bulletproof
From: padding: zero-pixels;
Registered: 2000-12-19
Posts: 16026
Website

Re: JS Form Question

Only if the two forms are from the same domain.  It's a javascript security issue built-in to most browsers.  i.e. you can't run a script from yourawesomesite.com to control a page on hiscrappypage.org

as a rule, that is.

Offline

 

#3 2005-06-20 9:46 am

zakatak
Member
From: Kalamazoo
Registered: 2004-08-05
Posts: 565

Re: JS Form Question

Okay, so if I have a page on rooistehroxorz.com and it makes a little popup and asks you some questions and then flags some checkboxes and submits the form that called it when you close the popup (not a crazy crappy popup, but a 'legit' style) then it should be doable...

Where might I find more information regarding how JS would handle that?

Offline

 

#4 2005-06-20 10:06 am

registered_user
bulletproof
From: padding: zero-pixels;
Registered: 2000-12-19
Posts: 16026
Website

Re: JS Form Question

well, your syntax looks right.

window.opener refers to the opening window object.

You might want to try something simpler and visual as a test.  Like altering an input value in window.opener and get that working before you try to submit.  The submit might be the cause of your problems.

It might be worth mentioning that submit() does not trigger the onsubmit event handler.

Offline

 

#5 2005-06-20 11:45 am

zakatak
Member
From: Kalamazoo
Registered: 2004-08-05
Posts: 565

Re: JS Form Question

Thanks roo, you're a genius.

I was trying to submit the form because I had built it funny, not because I had an onsubmit event handler... Turns out that all I really had to do was use innerHTML instead of my session variables... and what ended up being wrong was that I needed to affix a .document to my window.opener

Thanks again. Your recomendation to try something 'simpler and visual' let me realize I was doing what I wanted to do all backwards and stupid... smile

Offline

 

Board footer

Powered by PunBB 1.2.6
© Copyright 2002–2005 Rickard Andersson