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

Mulitple Input Values passed from Popup Window

OK, I need to do three different things.

On the ONLOAD event I would like a popup box to open. In this popup
box I need two text boxes. One for the UserName and one for the
BillingTo name. After entering these two items the user can either hit
the enter key or press the submit button. The popup window will close
and then those two text boxes in the original webpage will be filled in
automatically.

I would like to have the two fields to be validated so the popup won't
close until both text boxes are filled in.

So far I have used the function from javascript.internet.com in the
header of the original page. I have tried to make so that when the
first popup closes the second popup will open. I can get the variables
to pass the main page but I feel it would be more effecient to have
both text boxes in the same popup instead of having two.

<html>
<head>
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function explain(name, output) {
newwin = window.open('','','top=150,left=150,width=325,heig ht=300');
if (!newwin.opener) newwin.opener = self;
with (newwin.document)
{
open();
write('<html>');
write('<body onLoad="document.form.box.focus()"><form name=form
onSubmit=window.close()> <br>');
write('<p>' + name + ' ');
write('<p><center> Sender: <input type=text name=box size=20
onKeyUp=' + output + '=this.value>');
write('<p><input type=button value="Click to close when finished"
onClick=window.close()>');
write('</center></form></body></html>');
close();
}
}

// End -->

<!-- Begin
function billingto(name, output) {
newwin = window.open('','','top=150,left=150,width=325,heig ht=300');
if (!newwin.opener) newwin.opener = self;
with (newwin.document)
{
open();
write('<html>');
write('<body onLoad="document.form.box.focus()"><form name=form
onSubmit=window.close()> <br>');
write('<p>' + name + ' ');
write('<p><center> Sender: <input type=text name=box size=20
onKeyUp=' + output + '=this.value>');
write('<p><input type=button value="Click to close when finished"
onClick=window.close()>');
write('</center></form></body></html>');
close();
}
}
// End -->

</script>
</head>

<body ONLOAD="explain('Please enter the name of the person sending this
shipment here and it will be copied into the form for you.',
'opener.document.form.username.value');">
<center>
<form name=form method=post>

User Name: <input type=text name="username" size=10
onfocus="billingto('Please enter the billing to person',
'opener.document.form.billing.value');">

<br>
Password: <input type=text name="billing" size=10>

</form>
</center>

</BODY>
</html>

Thanks for any help - Billy

Mar 24 '06 #1
2 6896
I have figured out how to have both text boxes into one popup and how
to get those values passed to the main page. Here is the code in my
head tag:

<!-- Begin
function shippingform(name, billing, output, output2) {
newwin = window.open('','','top=150,left=150,width=500,heig ht=200');
if (!newwin.opener) newwin.opener = self;
with (newwin.document)
{
open();
write('<html>');
write('<body onLoad="document.form.box.focus()">');
write('<form name=form onSubmit=window.close()>');
write('<center>');
write('<br>');
write(name);
write('<br>');
write('Sender: ');
write('<input type=text name=box size=20 onKeyUp=' + output +
'=this.value>');
write('<br>');
write('<br>');
write(billing);
write('<br>');
write('BillingTo: ');
write('<input type=text name=billingtobox size=20 onKeyUp=' + output2 +
'=this.value>');
write('<br>');
write('<input type=button value="Click to close when finished"
onClick=window.close()>');
write('</center>');
write('</form>');
write('</body>');
write('</html>');
close();
}
}

// End -->

</script>
=======================
=======================

Here is my body tag:
<body ONLOAD="shippingform('Please enter the name of the person sending
this shipment here.', 'Enter Advanced.1, Client, or Personal for
verification on who will get billed',
'opener.document.form.username.value',
'opener.document.form.billingtobox.value');">
<form method="POST" name="form">

=======================
=======================

Here are the text boxes on the main page:

<input type="text" name="username" size=53>
<input type=text name="billingtobox" size=81>

=======================
=======================

The only thing I really need now is for some kind of verification to
happen. I don't want the popup to close until both fields are filled
in.

Also, somehow the onsubmit stopped working. So the only way to close
the popup is to click the button or click the red X. Any suggestions?

Thanks.

Mar 24 '06 #2
ja*********@gmail.com wrote:
I have figured out how to have both text boxes into one popup and how
to get those values passed to the main page. Here is the code in my
head tag:
You mean the `head' _element_, which consists of an optional
start tag, content, and an optional end tag, in HTML 4.01.
<!-- Begin
Obsolete, potentially harmful nonsense. Remove it.
function shippingform(name, billing, output, output2) {
newwin = window.open('','','top=150,left=150,width=500,heig ht=200');
I hope `newwin' is declared somewhere with `var'.
if (!newwin.opener) newwin.opener = self;
Nonsense, remove it.
with (newwin.document)
{
The `with' statement is deprecated because of its side effects, and it is
unnecessary here.
open();
write('<html>');
The markup that you are generating (and that contains the generating code)
is not Valid HTML.

<URL:http://validator.w3.org/>
write('<body onLoad="document.form.box.focus()">');
Consecutive calls of document.write() are inefficient and error-prone,
especially when only a tag and not the whole element is written. Should
be more like

newwin.document.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'
+ ' "http://www.w3.org/TR/html4/loose.dtd">'
+ '<html>'
+ ...);

The most efficient way is joining an Array:

newwin.document.write([
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"',
' "http://www.w3.org/TR/html4/loose.dtd">',
'<html>',
...
].join('\n'));

The latter is supposed to work since JavaScript 1.3 (NN 4.06, 1998 CE),
JScript 2.0 (IE 2.0, 1996/1997 CE), and in ECMAScript Edition 3 (December
1999 CE) implementations.
[...]
// End -->
Unnecessary. Remove it.
[...]
<body ONLOAD="shippingform('Please enter the name of the person sending
this shipment here.', 'Enter Advanced.1, Client, or Personal for
verification on who will get billed',
'opener.document.form.username.value',
'opener.document.form.billingtobox.value');">
Element types _and_ attribute names should be lowercase, even though
HTML is case-insensitive regarding this.

When event handler code turns into spaghetti code like this, it should
be moved into a function, and that function should be called instead.
<form method="POST" name="form">
The `action' attribute is missing, and the form most certainly does not
need a name. There is the document.forms collection; if the form is
the first or only one within the document, it can be referred backwards
compatible and standards compliant with `document.forms[0]'. The name
`form' is unwise anyway, especially when used in proprietary syntax
`document.form' because `document.forms' exists.
[...]
Here are the text boxes on the main page:

<input type="text" name="username" size=53>
type="text" is redundant here, and all attribute values should be quoted.
<input type=text name="billingtobox" size=81>
[...]
The only thing I really need now is for some kind of verification to
happen. I don't want the popup to close until both fields are filled
in.
Your current code will close the window before anything of the input can
be processed or submitted, due to `onsubmit=window.close()' [where the
attribute value MUST be enclosed in single or double quotes because of
the `(' or `)'].

Return `false' to the `onsubmit' handler if you want the form not to be
submitted, and do not call window.close() unconditionally if you do not
want the window to be closed always.
Also, somehow the onsubmit stopped working.
It never worked this way. `onsubmit' code is executed when the `submit'
event of the form occurs, i.e. if the submit button is activated or
(usually) the Return key is pressed when an input control has focus,
_before_ the form is actually submitted.
So the only way to close the popup is to click the button or click the
red X.
There is no red X here. You must be talking about one of the dozens of
window managers or user agents out there.
Any suggestions?


Read the FAQ, search the archives, so get a minimum clue,
and then get back here. <URL:http://jibbering.com/faq/>
PointedEars
Mar 24 '06 #3

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

Similar topics

4
by: Peter Kirk | last post by:
Hi, I want to open a popup-window which displays a list to the user. From this list, the user can select an item, and the data regarding this item is then transferred to some fields on the main...
6
by: veganeater | last post by:
Hi Everyone, I was wondering if there was a way to pass a variable to a popup window. The purpose is make it so when a user clicks on a specific region/link of the glossary page, a popup opens...
2
by: maxrawson | last post by:
Greetings all: I have an asp.net application that is coded mainly in vb.net. I have successfully cut and pasted some javascript into my application that mimicks the datetime picker control in...
5
by: Steve | last post by:
Hi, I currently have a problem passing a variable value from one page to another. Once a form submit button is pressed java pops up a window and displays some information. The problem being is...
1
by: neena | last post by:
anyone please tell me how to pass the selected value from a listbox in popup window(child window) ,created using window.open() in javascript ,to a textbox in parent window please help me...
3
by: simora | last post by:
Hi: Need some working sample code to post hidden form data from a php page to a new popup window. 540 x 500 centered. The popup that I'm calling already is formatted and has a TITLE:web-2007.php...
1
by: selvamsivalingam | last post by:
i call the popup window through javascript by using the below code. <script language="javascript"> function hpclick() { var WinSettings =...
18
by: vjayis | last post by:
hi i am having a form which contains an text field., when the submit button is clicked the value of the textfield should be taken into the new popup window to display the results. i had...
11
by: V S Rawat | last post by:
using Javascript, I am opening a web-based url in a popup window. MyWin1=Window.Open(url, "mywindow") There is a form (form1) in the url in that popup window, I need to submit that form. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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
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...

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.