By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,400 Members | 1,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,400 IT Pros & Developers. It's quick & easy.

window.opener, form.opener?

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.