473,413 Members | 1,713 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,413 software developers and data experts.

JS opening two windows instead of one

When this form's being submitted, two windows are opening instead of only
one
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
subWin =
window.open("http://www.smoochya.com/books.html","subWin","width=550,height=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.target = subWin
document.SendScore.submit()
}

here is the form in the HTML body:
<FORM NAME="SendScore" >
<INPUT TYPE="hidden" name="numbercorrect" value="">
<INPUT TYPE="IMAGE" onClick="subForm()" SRC="/images/passitalong_quiz.jpg"

</FORM>

the only other thing going on which probably is not interfering is the fact
that I'm making that "hidden" variable switch to a javascript variable from
being submitted by another form page that comes before this one.
I'm calling it in the BODY tag using onLoad="javascript:
SwitchNumberRight();" which calls this function:

function SwitchNumberRight(){
document.SendScore.numbercorrect.value = numberright;
}

anyway the code can be viewed by going to http://www.smoochya.com/quiz1.html
and picking some answers (or not picking any) on the quiz. You'll notice
that one of the windows gives you your score while the other one (without
any toolbars) doesn't. Can't seem to get it to open only one window with the
score included.

Any help greatly appreciated..
Thanks,
M
Jul 20 '05 #1
3 1695
Lee
Display Name said:

When this form's being submitted, two windows are opening instead of only
one
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
subWin =
window.open("http://www.smoochya.com/books.html","subWin","width=550,height=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.target = subWin
document.SendScore.submit()
}


You're getting a second window because the window you open()
is not being set as the target of the form.

document.SendScore.target = "subWin"

The value of the target attribute is the name of the window, not
a reference to the window.

Jul 20 '05 #2
@SM


Lee a *crit :
Display Name said:

When this form's being submitted, two windows are opening instead of only
one
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
change the name of your popup
subWin =

popWin=
window.open("http://www.smoochya.com/books.html","subWin","width=550,height=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.method = "get"
document.SendScore.target = subWin
document.SendScore.target = "subWin"
document.SendScore.submit()
}


You're getting a second window because the window you open()
is not being set as the target of the form.


and this window has same name as target ...
document.SendScore.target = "subWin"

The value of the target attribute is the name of the window, not
a reference to the window.


I think (but I could bad understand you) that the 'target'
is the target included in the window
truc = window.open('url','target','attributes');
or with :
truc=window.open('page.htm','chose','width=300,hei ght=300,resizable=0');

onclick="truc.location = 'page_2.htm';"
would work as
<a href="page_2.htm" target="chose">page 2</a>
--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanemoriaux/internet/
************************************************** ************
Jul 20 '05 #3
Stephane...
you're the man. your edits worked even w/o having to adjust the target
parameters. thanks a lot!
M

"@SM" <st**************@wanadoo.fr> wrote in message
news:3F***************@wanadoo.fr...


Lee a *crit :
Display Name said:

When this form's being submitted, two windows are opening instead of onlyone
here is the function I'm using:

function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
change the name of your popup
subWin =


popWin=

window.open("http://www.smoochya.com/books.html","subWin","width=550,height

=
350,address=no")
document.SendScore.action = "tellafriend_quiz1.php"
document.SendScore.method = "post"
document.SendScore.method = "get"
document.SendScore.target = subWin
document.SendScore.target = "subWin"
document.SendScore.submit()
}


You're getting a second window because the window you open()
is not being set as the target of the form.


and this window has same name as target ...
document.SendScore.target = "subWin"

The value of the target attribute is the name of the window, not
a reference to the window.


I think (but I could bad understand you) that the 'target'
is the target included in the window
truc = window.open('url','target','attributes');
or with :
truc=window.open('page.htm','chose','width=300,hei ght=300,resizable=0');

onclick="truc.location = 'page_2.htm';"
would work as
<a href="page_2.htm" target="chose">page 2</a>
--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanemoriaux/internet/
************************************************** ************

Jul 20 '05 #4

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

Similar topics

14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
2
by: Matt Hamilton | last post by:
I have an application page with a datagrid with a checkbox on each row. The user should check the rows they want to modify and then click a button. When the button is clicked, I have a Click...
4
by: CliffKing | last post by:
I am trying to use Windows Task Scheduler to run a batch file for an already open MS Access database. Below is the syntax to the batch file: Batch file: DailySalesExport.bat REM This runs the...
8
by: Claudio Grondi | last post by:
Here an example of what I mean (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte large file): Traceback (most recent call last): File "<pyshell#1>", line 1, in -toplevel-...
11
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of...
1
by: T | last post by:
Currently there is an excel shortcut available on the network with links to 30 or so access db (97 & 2003), since the users are complaining about all the messages from excel (already open, do you...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
3
by: =?Utf-8?B?TGllbGE=?= | last post by:
I have a user who stores her documents on a different drive and when she attempts to open documents it auto defaults to My Documents instead of her other drive. Is there a way to change the...
1
by: santoshmaya | last post by:
When opening a PDF over SSL running on IIS 5.1 (Windows XP Professional, W2K Windows 2000, or Windows Server 2003), you may receive the following problem with Internet Explorer. First, instead of...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.