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

window.opener, form.opener?

I see how the window.opener works, pretty neat in that the pop window
knows the parent.

Is there a property that also knows the form field parent?

My function does not know which of the 3 select menus called it.

What can I do?

function onCarrierSelect() {
//
var frm = document.carrRequestForm.carrierList.selectedIndex
var selectCar =
document.carrRequestForm.carrierList.options[frm].text;
alert(selectCar);
if (window.opener && !window.opener.close)
window.opener.document.form(x how make global?).nbcarrier(x how make
global?).value = selectCar
window.close();
}
p.s. as an aside I know the form field name, it is literally in the
querystring, but that is ASP/vbscript and no way to get it into the
jscript function...

Jul 14 '06 #1
4 6129
I may be able to get help writing a cookie, which I find unbelievably
hard (compared to ASP)..
I know the value of the form field in my function that is called first.
I see it when I do alert(formEl.name); pretty cool.
How do I put it in a cookie called "whichField"?

CODE:

function openCarrierWin(formEl) {
var formElement = formEl.options
if (formElement[formElement.selectedIndex].className == "newwin") {
window.open((formElement[formElement.selectedIndex].value),
"carrierWin", "resizable=1,height=625,width=700");
// set cookie here with the value of
alert(formEl.name);
}
else if (formElement[formElement.selectedIndex].value != "none") {
return false;
}
}
P.s. I have searched and searched on cookies but they are overly
complex. I will take a look at the FAQ page I got earlier and see if
your site explains cookies in javascript better. The thing is I dont
want to write function after function for cookies. In asp it is soo
easy. Response.Cookies("name") = "whichField" or something like that.
Can someone show me javascript like that in one line?
jo********@gmail.com wrote:
I see how the window.opener works, pretty neat in that the pop window
knows the parent.

Is there a property that also knows the form field parent?

My function does not know which of the 3 select menus called it.

What can I do?

function onCarrierSelect() {
//
var frm = document.carrRequestForm.carrierList.selectedIndex
var selectCar =
document.carrRequestForm.carrierList.options[frm].text;
alert(selectCar);
if (window.opener && !window.opener.close)
window.opener.document.form(x how make global?).nbcarrier(x how make
global?).value = selectCar
window.close();
}
p.s. as an aside I know the form field name, it is literally in the
querystring, but that is ASP/vbscript and no way to get it into the
jscript function...
Jul 14 '06 #2
jo********@gmail.com said the following on 7/14/2006 10:38 AM:
I see how the window.opener works, pretty neat in that the pop window
knows the parent.

Is there a property that also knows the form field parent?
A form field's parent? That would be the form.
My function does not know which of the 3 select menus called it.
Then tell it.
What can I do?
Have your select element pass a reference to itself.
function onCarrierSelect() {
function onCarrierSelect(selElem){

And call it as such: onCarrierSelect(this)

And then inside your function selElem will refer to the select element
that called the function.
//
var frm = document.carrRequestForm.carrierList.selectedIndex
frm refers to the selectedIndex of a Select element, frm is a misleading
var name for it.
var selectCar =
document.carrRequestForm.carrierList.options[frm].text;
alert(selectCar);
if (window.opener && !window.opener.close)
window.opener.document.form(x how make global?).nbcarrier(x how make
global?).value = selectCar
What form and what nbcarrier are you wanting to refer to?

All form elements have a form property. selectElement.form refers to the
parent form of the select list.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 14 '06 #3
Just wondering..

What I really need is to *NOT* change the .value OR .text but simply
*change* the select menu to the correct value in the parent select
menu.

How do I do that please?
function onCarrierSelect() {
var frm = document.carrRequestForm.carrierList.selectedIndex
var selectCar =
document.carrRequestForm.carrierList.options[frm].text;
var varEl = "<%=varElementName%>"
// alert(varEl); // test variable
if (window.opener && !window.opener.close)
window.opener.document.form(0).<%=varElementName%> .value
="selectCar";
window.close();
}
Thank you.
Lee wrote:
jo********@gmail.com said:

I may be able to get help writing a cookie, which I find unbelievably
hard (compared to ASP)..
I know the value of the form field in my function that is called first.
I see it when I do alert(formEl.name); pretty cool.
How do I put it in a cookie called "whichField"?

Just store a reference to the current field in a global variable
in the parent window. Then your child can update the field as:

window.opener.globalCurrentField.value="...";
--
Jul 14 '06 #4
I tried both:
window.opener.document.form(0).<%=varElementName%> .text =selectCar;
and:
I tried both
window.opener.document.form(0).<%=varElementName%> .select =selectCar;

But the thing is the Option I am attempting change does not exist, the
value/text WEST BEND AUTO does not exist then how do I create one on
the fly?

Because in order for the parent page to then *truly* be able to submit
the main form, dynamically this would *HAVE* to have been created.
<option value='WEST BEND AUTO'>WEST BEND AUTO</option>

Am I asking to much of a web application guys?

P.s. I have values for varElementName AND selectCar.

jo********@gmail.com wrote:
Just wondering..

What I really need is to *NOT* change the .value OR .text but simply
*change* the select menu to the correct value in the parent select
menu.

How do I do that please?
function onCarrierSelect() {
var frm = document.carrRequestForm.carrierList.selectedIndex
var selectCar =
document.carrRequestForm.carrierList.options[frm].text;
var varEl = "<%=varElementName%>"
// alert(varEl); // test variable
if (window.opener && !window.opener.close)
window.opener.document.form(0).<%=varElementName%> .value
="selectCar";
window.close();
}
Thank you.
Lee wrote:
jo********@gmail.com said:
>
>I may be able to get help writing a cookie, which I find unbelievably
>hard (compared to ASP)..
>I know the value of the form field in my function that is called first.
>I see it when I do alert(formEl.name); pretty cool.
>How do I put it in a cookie called "whichField"?
Just store a reference to the current field in a global variable
in the parent window. Then your child can update the field as:

window.opener.globalCurrentField.value="...";
--
Jul 14 '06 #5

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

Similar topics

1
by: Daniel Andersen | last post by:
Hi, Does anyone here know of a way of tracking the window that launched a popup window besides using window.opener? The problem i'm having is that the popup window submits a form within itself...
1
by: Tony Farrell | last post by:
Hi Everyone - I have a data entry form that allows the user to click a button and have that button popup a list of available values - the code on the popup window uses the name of the form to...
1
by: fogwolf | last post by:
First a basic outline of what I am trying to do: I want to have a page spawn a pop-up when you click "submit" on its form. On this pop-up page there will be another form. When you click "submit"...
2
by: Robert Nurse | last post by:
Hi All, I'm trying to alter the contents of a drop-down (select) list on the parent window from a child window in IE 6. After opening the child window, I set its opener to reference the parent...
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...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
5
by: Hemanth | last post by:
Hello there, I'm running a script that opens a popup window (which is basically a form with checkboxes and a submit button). When I click the submit button I want to run a PHP script and target...
2
by: jackson2005 | last post by:
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. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.