window.opener, form.opener?

J

jojowebdev

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...
 
J

jojowebdev

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?
 
L

Lee

(e-mail address removed) 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="...";


--
 
R

Randy Webb

(e-mail address removed) 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.
 
J

jojowebdev

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.
 
J

jojowebdev

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.

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 said:
(e-mail address removed) said:

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="...";


--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top