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

About opener.document.forms[0]

Hi,
I've been working with this without problems:

function regresaValor()
{
var indexValor = document.forms[0].eleccion.selectedIndex;
var valueValor =
document.forms[0].eleccion.options[indexValor].value;
opener.document.forms[0].valorTxt.value = valueValor;
window.close();
}

As you can see, this JS function returns 1 value to the parent.
However, I'm trying to return several values to the same parent's
element (valorTxt). Something like this:

function regresaValor()
{
var indexValor0 = document.forms[0].eleccion0.selectedIndex;
var valueValor0 =
document.forms[0].eleccion0.options[indexValor].value;
var indexValor1 = document.forms[0].eleccion1.selectedIndex;
var valueValor1 =
document.forms[0].eleccion1.options[indexValor].value;
var indexValor2 = document.forms[0].eleccion2.selectedIndex;
var valueValor2 =
document.forms[0].eleccion2.options[indexValor].value;
var total = valueValor0 + ";" + valueValor1 + ";" valueValor2;
opener.document.forms[0].valorTxt.value = total;
window.close();
}

This should return a String value to the parent, where I can do
further analysis.

Is this approach the best? Can it be done? Thank you for your time and
advices.

- Omar.
Jul 23 '05 #1
4 7057
Omar wrote:
Hi,
I've been working with this without problems:

function regresaValor()
{
var indexValor = document.forms[0].eleccion.selectedIndex;
var valueValor =
document.forms[0].eleccion.options[indexValor].value;
opener.document.forms[0].valorTxt.value = valueValor;
window.close();
}

As you can see, this JS function returns 1 value to the parent.
However, I'm trying to return several values to the same parent's
element (valorTxt). Something like this:

function regresaValor()
{
var indexValor0 = document.forms[0].eleccion0.selectedIndex;
var valueValor0 =
document.forms[0].eleccion0.options[indexValor].value;
var indexValor1 = document.forms[0].eleccion1.selectedIndex;
var valueValor1 =
document.forms[0].eleccion1.options[indexValor].value;
var indexValor2 = document.forms[0].eleccion2.selectedIndex;
var valueValor2 =
document.forms[0].eleccion2.options[indexValor].value;
var total = valueValor0 + ";" + valueValor1 + ";" valueValor2;
opener.document.forms[0].valorTxt.value = total;
window.close();
}

This should return a String value to the parent, where I can do
further analysis.

Is this approach the best? Can it be done? Thank you for your time and advices.

- Omar.


You don't necessarily need to send that to a text input (which is not a
programming construct) to 'analyze' it...depends on what you had in
mind. #;-)

Anyway...

function regresaValor()
{
var els = document.forms[0].elements,
opform, valorTxt, sel, n = 0, els,
data = [];
if (opener
&& !opener.closed
&& (opform = opener.document.forms[0])
&& (valorTxt = opform.elements.valorTxt))
{
while (sel = els['eleccion' + n++])
data.push(sel.value);
valorTxt.value = data.join('; ');
}
window.close();
}

Will process elements named 'eleccion0', 'eleccion1', etc., until there
isn't one. Array.push() adds to the end of the array, .join() pastes
the elements into a string with its argument as seperator. Just one
approach.

Jul 23 '05 #2
ro*****@yahoo.com (Omar) wrote in message news:<8b**************************@posting.google. com>...
Hi,
I've been working with this without problems:

function regresaValor()
{
var indexValor = document.forms[0].eleccion.selectedIndex;
var valueValor =
document.forms[0].eleccion.options[indexValor].value;
opener.document.forms[0].valorTxt.value = valueValor;
window.close();
}

As you can see, this JS function returns 1 value to the parent.
However, I'm trying to return several values to the same parent's
element (valorTxt). Something like this:

function regresaValor() {
var indexValor0 = document.forms[0].eleccion0.selectedIndex;
var valueValor0 =
document.forms[0].eleccion0.options[indexValor].value;
var indexValor1 = document.forms[0].eleccion1.selectedIndex;
var valueValor1 =
document.forms[0].eleccion1.options[indexValor].value;
var indexValor2 = document.forms[0].eleccion2.selectedIndex;
var valueValor2 =
document.forms[0].eleccion2.options[indexValor].value;
var total = valueValor0 + ";" + valueValor1 + ";" valueValor2;
opener.document.forms[0].valorTxt.value = total;
window.close();
}

This should return a String value to the parent, where I can do
further analysis.

Is this approach the best? Can it be done? Thank you for your time and
advices.

- Omar.

i don't know exactly but what value is the function returning ???
try using ',' instead of ';' maybe that will help.
Jul 23 '05 #3
RobB wrote:
[...]
Anyway...

function regresaValor()
{
var els = document.forms[0].elements,
opform, valorTxt, sel, n = 0, els,
data = [];


You have declared 'els' twice, but (to my surprise) it doesn't seem
to cause an error. Even something like:

var els = document.forms[0].elements;
var els;

does not seem to be an issue. I guess this highlights that a variable
is not given a value until it is assigned one, so simply initialising
'els' a second time does nothing?
[...]
--
Rob
Jul 23 '05 #4
RobG wrote:
RobB wrote:
[...]
Anyway...

function regresaValor()
{
var els = document.forms[0].elements,
opform, valorTxt, sel, n = 0, els,
data = [];


You have declared 'els' twice, but (to my surprise) it
doesn't seem to cause an error. Even something like:

var els = document.forms[0].elements;
var els;

does not seem to be an issue. I guess this highlights that a
variable is not given a value until it is assigned one, so
simply initialising 'els' a second time does nothing?


It is more surprising to find that:-

var els;
var els = document.forms[0].elements;

- also works, and results in - els - having the assigned value in
subsequent code. But ECMA 262 Section10.1.3 explains why it is not a
problem. But also why there is wasted processing in defining local
variables more than once.

Richard.
Jul 23 '05 #5

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

Similar topics

1
by: David Cohen | last post by:
From the main window, I'm opening a popup window. In that poupup window, the user loads a number of different pages (by submitting forms and clicking on buttons), some of which are in a...
7
by: Marco Alting | last post by:
Hi, I want to use the submit button of a new window to submit the form of the new window (which carries two values to the opener window) and then submit the opener form. Can anyone tell me...
2
by: Stefan Sch?rmeli | last post by:
I already read about several problems using firefox and the window.opener property. But obviously it didn't help out. So here is my problem: I got a "Search..." link which opens a new window...
18
by: q2005 | last post by:
Hi, all When I do as the following, it becomes a GET action to the the server. How do I make it as a POST action? That means I don't want the string after "?" show on URL bar and, to the...
3
by: ctrl+alt+delete | last post by:
I have a normal window cotaining a form (named form1). The form has a text input called imageURL. There is a button that, when clicked, opens a new window that contains three frames (left, right...
3
by: Soren Schimkat | last post by:
Hi This works fine and adds a new element to the list: document.forms.elements.options = new Option('foo', 'bar'); ... but using the following code in a popup window - IE crashes or...
5
by: drdave | last post by:
Hi, I have 6 forms being generated using coldFusion, they are named special1, special2 special3 and so on.. in these forms I have a link to open a new window. I am trying to pickup the...
7
by: Alan Little | last post by:
I have a popup which contains a frame set; one of the frames contains a form. When the form is submitted, I want it to go back to the opener of the popup. I have: document.forms.target =...
2
by: TH | last post by:
Hi there What's the best way for a popup to cause an event to fire in the opener? I've got a popup which currently returns a value to the opener by setting a hidden input in the opener: ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.