Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transfer values of select box from popup to textbox in a parent window 2

Status
Not open for further replies.

daveigh

Programmer
Oct 9, 2003
105
my prob is, i want to transfer the values of the 3 select boxes to a parent window named opener. but whenever i try to, i always get this error: expected identifier.

i transfer the value of the select box (located in a popup window) to a textbox (located in parent window, named opener):

opener.document.form1.["p_quantity" + c]value = document.form2.p_quantity.value;

i tried debugging and found out that the error comes from this line:

alert(opener.document.form1.["pid_ordered" + c]value));

can somebody help me? thanks!

_______________CRYOcoustic_____________
 
a55mOnk, icy111,

That'll be great if you guys are working on the same thing,
icy let us know if this example doesn't do what you need.

Give this a try tell us how close it is...
Save these two pages in the same dir. load master and try
it out.
Code:
##  ---- master.html ----  ##

<html><head><script>
</script></head>
<form name=&quot;test&quot;>
<input type=&quot;text&quot; name=&quot;recstr&quot; size=&quot;30&quot;>
</form>
<a href=&quot;#&quot; onClick=&quot;javascript:window.open('zipfrm.html','');&quot;>New Win</a>
</body></html>

##  ---- zipfrm.html  ----  ##

<html><head><script>
function snd(frm){
tmp = &quot;&quot;;
for(i=0;i<frm.elements.length;i++){
    el = frm.elements[i];
  if(el.type == 'checkbox' && el.checked == true){
   tmp += el.value+','; }}
tmp = tmp.substring(0,tmp.length-1);
opener.document.test.recstr.value = tmp;
self.close();
}
</script></head><body><form>
<input type=&quot;checkbox&quot; value=&quot;Gandor&quot;>Gandor<br>
<input type=&quot;checkbox&quot; value=&quot;Frodo&quot;>Frodo<br>
<input type=&quot;checkbox&quot; value=&quot;Sam&quot;>Sam<br>
<input type=&quot;checkbox&quot; value=&quot;Strider&quot;>Strider<p>
<input type=&quot;button&quot; value=&quot;Add&quot; onclick=&quot;snd(this.form)&quot;>
</form></body></html>


2b||!2b
 
Hi Lrnmore

i think my explanation was bad, very sorry.
Based on a55mOnk's issue. is quite similar to mine.

I will give it a try.

Thanks

Merry christmas to all.

regards
icy111
 
Hi !!!
1st. Sorry for my english, i am learning ha ha ha..
well..
anybody can help me ?

i want copy a selected items from a select box in a popup window to a parent window select box...

maybe you don´t understand my explantion.. but i try..

tnx !
and happy new year.
 
NeaNDegoR,

In this the onChange of the select in the popup sends it's
value to a function in the opener. The opener finds the
&quot;option&quot; with the same value and selects it.

If it doesn't do what you need let us know..

Code:
<html><head><script>
function mkwin(){
pup = window.open();
pup.document.write('<html><head><script>function snd(val){\n'+
'opener.rcsel(val); self.close();}\n'+
'<\/script></head><body><form name=&quot;test&quot;>\n'+
'Less Than Three, More Than One.<br>\n'+
'<select name=&quot;sela&quot; onChange=&quot;snd(this.value)&quot;>\n'+
'<option value=&quot;&quot;>Select One</option>\n'+
'<option value=&quot;1&quot;>One</option>\n'+
'<option value=&quot;2&quot;>Two</option>\n'+
'<option value=&quot;3&quot;>Three</option></select>\n'+
'</form></body></html>\n');
pup.document.close();
pup.focus();
}
function rcsel(val){
d = document.form1.sela;
for(i=0;i<d.length;i++) {
 if(d.options[i].value == val) {
   d.options[i].selected = true;
   break; }}
}
</script></head><body>
<form name=&quot;form1&quot;>How Many Home Keys on
Your KeyBoard?<br>
<select name=&quot;sela&quot;>
<option value=&quot;&quot;>Select One</option>
<option value=&quot;1&quot;>One</option>
<option value=&quot;2&quot;>Two</option>
<option value=&quot;3&quot;>Three</option></select>
</form>
For More Info <a href=&quot;javascript:mkwin()&quot;>
Click Here</a>.</body></html>
 
Lrnmore, following your input to this thread, you seem like the kinda person who may be able to answer my question on popups. (please - begging tone!)

Is it possible to popup a new window which is on a different domain, do some stuff in the popup, then auto-close the popup and reopen the main window (on dif. domain)?

So far, I have the following:
on domain1, I have a booking form and is therefore on my secure domain (SSL). Part way thru, the user may need to do an address lookup based on their postcode. We use third party scripts for this, therefore, if I included it on domain1, the user would get a 'do you want to display nonsecure items' message - as the scripts are external.

To avoid this happening - (imagine how many orders I might lose as the users may well mis-interpret this - or just get annoyed as they may have to click on yes over several pages) - I am using a popup (on domain2). The user can then go thru the address lookup process with no bother.

At the end of the process, I need the popup to close and reopen the main window, and pass thru the parameters via querystring (which is how they are sent back to me).

I can do all this using window.opener:

window.opener.location.href=&quot;
window.close();

but it is not really loading the page properly. The images do not load, though the form is still there. When I try submitting the form (regardless of whether the graphics are there or not), it cannot load the next page as it cannot find it (it works fine normally).

Despite the address bar and the page properties are stating that it is the page I want, it is not properly loading it.

I have even tried -
at the end of my popup, I redirect the page (inc. querystring) to a page on my secure server. I then use the window.opener script but it still doesn't work properly (i do get some graphics but the form still won't process). I figured if I transfer it back to the right domain then it might be able to open it.

Do you have any suggestions? Sorry for the long explanation and I hope it makes sense!

Thanks
 
Biffy13,

What is the purpose of the,
window.close();

If it is the opener you are referring to try leaving
that statement out and see what happens.

The other thing that comes to mind is to fill out a form
(in the opener) based on the info in the pop-up.

Then with a function call submit the form in the opener,
returning the page you are looking for in the &quot;opener&quot;
window.

But, I don't have any experience with crossing domains or
I would comment.

Maybe someone else has an idea for you along those lines.

Let us know how it works out.
 
Thanks Lrnmore.

The window.close() is to close the popup window after it has re-opened the main window (using the window.opener).

My problem with using cross-domains is that the main window is getting confused about which domain it should be on! I have come up with the solution of using the window.opener() to open a different script (on the same site as the popup) which then does a redirect via ASP back to the main page.

To me, in theory this should work, but it isn't completely. I do get some graphics but I cannot submit the form as it cannot find the page (it submits to itself). I am going to try redirecting the main page to itself once it's been redirected to to see if that helps. A complete bodge but I'm getting desperate as this needs to be done for Monday ;)

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top