473,405 Members | 2,310 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,405 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 6907
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...

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.