Need Help for Pop Up windows

R

rkuwadia

Guest
Hello,

I have a script in which from parent browser, I open a pop up window.
Clicking submit on Pop up window, should close the pop up window and submit the
values to the parent window.


The code on parent window(say parent.php) is something like this:

<script language=javascript>
window.name="jobpost";
window.open('xyz.php', 'xxx');
</script>

The code on xyz.php is something like this:
<form name=form1 method=post target=jobpost>
<input type=button value="Apply" onclick="javascript:OnApply();">
</form>


<script language=javascript>
function onApply(){
document.form1.action="parent.php";
document.form1.submit();
self.close();
}
</script>


The above code works on windows IE as well as NN.
But it doesnot work on Mac. It gives lot of errors . When I do not submit to parent window, no error comes.


Can anyone help me on this issue?I have no button named Submit in pop up window as well as parent window.

Thanks
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
Ok here is my popup code...

Code:
function popup( page, title, w, h, scroll ) {
  if (!title) title = 'Popup';
  if (!scroll) scroll = 'no';
  if (!w) w = 500;
  if (!h) h = 350;
  var wintop = (screen.height - h) / 2;
  var winleft = (screen.width - w) / 2;
  var atts = 'width='+w+',height='+h+',scrollbars='+scroll+',resizable,screenX=150,screenY=150,top='+wintop+',left='+winleft+'';
  win = window.open( page, title, atts);
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

When submitting to the parent window use

Code:
top.opener.location.href

If you need more help please reply and we'll go through everything that you are doing.. it would help to see exactly what your code is.. maybe even a working example or at least the non working one :)

Cheers!
 
OP
R

rkuwadia

Guest
Thanks for this much help.

The problem is I need values from pop up window into the parent window.

If I use, top.opener.location.href, then the page doesnot get submitted and I donot get values.

If I use javascript to assign values, like top.opener.form1.field1.value it gives problem with array elements.

I am using php to code.

I have a field called grades which is an array.
So to use something like following, doesnt work in Javascript.

document.popup.grades[].value = top.opener.posting.grades[].value;


Do you have any suggestion for the above problem?
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
Hmm... I see what you are saying.. Ok what I would do is submit the form to <?=$_SERVER["PHP_SELF"]?> then parse your post variables

PHP:
// Get the number of values in $grades array
$numGrades = count($_POST['grades']);

// Go through every grade value and assign a new variable name
for ($i=0; $i<$numGrades; $i++)
  $gradeArr[] = "grades{$i}=".$_POST['grades'][$i];

// Transform the array into a URL string
$grades = implode('&', $gradeArr);

// You might want to urlencode the string afterwards
$grades = urlencode($grades);

This will stick your array into this form:

grade1=value&grade2=value&grade3=value

so forth and so forth.. that should help you out a bit there..
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top