Hi,
I've been working with this without problems:
function regresaValor()
{
var indexValor = document.forms[0].eleccion.selec tedIndex;
var valueValor =
document.forms[0].eleccion.optio ns[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.sele ctedIndex;
var valueValor0 =
document.forms[0].eleccion0.opti ons[indexValor].value;
var indexValor1 = document.forms[0].eleccion1.sele ctedIndex;
var valueValor1 =
document.forms[0].eleccion1.opti ons[indexValor].value;
var indexValor2 = document.forms[0].eleccion2.sele ctedIndex;
var valueValor2 =
document.forms[0].eleccion2.opti ons[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. 4 7067
Omar wrote: Hi, I've been working with this without problems:
function regresaValor() { var indexValor = document.forms[0].eleccion.selec tedIndex; var valueValor = document.forms[0].eleccion.optio ns[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.sele ctedIndex; var valueValor0 = document.forms[0].eleccion0.opti ons[indexValor].value; var indexValor1 = document.forms[0].eleccion1.sele ctedIndex; var valueValor1 = document.forms[0].eleccion1.opti ons[indexValor].value; var indexValor2 = document.forms[0].eleccion2.sele ctedIndex; var valueValor2 = document.forms[0].eleccion2.opti ons[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.v alue);
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. ro*****@yahoo.c om (Omar) wrote in message news:<8b******* *************** ****@posting.go ogle.com>... Hi, I've been working with this without problems:
function regresaValor() { var indexValor = document.forms[0].eleccion.selec tedIndex; var valueValor = document.forms[0].eleccion.optio ns[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.sele ctedIndex; var valueValor0 = document.forms[0].eleccion0.opti ons[indexValor].value; var indexValor1 = document.forms[0].eleccion1.sele ctedIndex; var valueValor1 = document.forms[0].eleccion1.opti ons[indexValor].value; var indexValor2 = document.forms[0].eleccion2.sele ctedIndex; var valueValor2 = document.forms[0].eleccion2.opti ons[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.
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
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
different domain. But eventually, the user comes back to a page that is
in the same domain as the page in the main window.
On this page, I'm trying to...
|
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 how to do this?
|
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 with an FTP-browser.
function popup(url,width,height){
var popupX = (screen.width/2)-(width/2);
var popupY = (screen.height/2)-(height/2);
var pos...
|
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 server, it can follow POST function to get the
data passed in. Thank you very much!
window.open("../../Server.php?"+xsValue, "", zNONHTML_STYLE);
|
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 and bottom.) In the right
frame is another form (named form2) with a hidden input (selected). When
form2 is submitted, I want the value of selected to...
| |
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 tells
|
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 formname passed along to the new window.. the
window opener function is:
<SCRIPT LANGUAGE = "JavaScript">
|
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 = parent.opener;
But on submit it opens a new window. If I put:
document.write(parent.opener.name);
|
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:
window.opener.document.forms.myHiddenField.value=returnValue;
window.close();
I then want the opener window to perform some work on the returned
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |