Digital Point Forums
Moneygram

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Oct 25th 2005, 12:48 pm
FRYO FRYO is offline
Champion of the Naaru
 
Join Date: Sep 2005
Posts: 220
FRYO is an unknown quantity at this point
Passing variables from pop-up window to parent window.

Hello,

I made a code to pass variables from pop-up window to parent window. Unfortunately this code is only working on Mozilla FireFox and not Internet Explorer. Can anyone help in this?

JavaScript function to pass variables and close pop-up window:
Code:
	function setValues()
	{
		var txt = document.getElementById("text").value;
		var font_size = document.getElementById("font_size").value;
		var font = document.getElementById("font");
		font = font.options[font.selectedIndex].value;
		var text_location = document.getElementById("text_location");
		text_location = text_location.options[text_location.selectedIndex].value;
		var color = document.getElementById("color").value;
		
		if (txt.length < 1 || font.length < 1 || font_size.length < 1 || font_size.toInt() < 1 || 
				font.length < 1 || text_location.length < 1 || color.length != 7 || color[0] != '#')
		{
			alert("Please fill out all the fields correctly!");
			return false;
		}
		
		var ncolor = parseInt(color.substr(1,2), 16) + "," + parseInt(color.substr(3,2), 16) + "," + parseInt(color.substr(5,2), 16);
		
		
		opener.document.getElementById("text").value = txt;
		opener.document.getElementById("font").value = font;
		opener.document.getElementById("font_size").value = font_size;
		opener.document.getElementById("text_location").value = text_location;
		opener.document.getElementById("color").value = ncolor;
		self.close();
		return false;
	}
Reply With Quote
  #2  
Old Oct 26th 2005, 4:38 am
dave487 dave487 is offline
Twilight Vanquisher
 
Join Date: Apr 2004
Location: Manchester
Posts: 701
dave487 is on a distinguished road
I do this with the following script, it works in IE:

Main page:
html4strict Code:
<form>
<input type=button name=choice onClick="window.open('page.php3','popuppage','width=850,toolbar=1,resizable=1,scrollbars=yes,height=700,top=100,left=100');" value="Select from Database">
</form>
Popup page:
html4strict Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function sendValue<?php echo "" . $data['id'] . ""; ?>(s){
var selvalue = s.value;
window.opener.document.form.details.value = selvalue;
window.opener.document.form.id.value = <?php echo "" . $data['id'] . "";?>;
window.close();
}
//  End -->
</script>
<form name="selectform<?php echo "" . $data['id'] . "";?>">
<input type="hidden" name="details" value="<?php echo "" . $data['name'] . "" ?> <?php echo "" . $data['address'] . "" ?> <?php echo "" . $data['phone'] . "" ?>">
<input type=button value="Copy to Form" onClick="sendValue<?php echo "" . $data['id'] . "";?>(this.form.details);">
</form>
__________________
SEO SEO John Chow
Reply With Quote
  #3  
Old Oct 30th 2005, 10:52 am
FRYO FRYO is offline
Champion of the Naaru
 
Join Date: Sep 2005
Posts: 220
FRYO is an unknown quantity at this point
Thanks for your help Dave but I dont think this is working with me.

Anybody else can help?
Reply With Quote
  #4  
Old Nov 11th 2008, 4:29 pm
killer2021's Avatar
killer2021 killer2021 is offline
Twilight Vanquisher
Recent Blog: lineage 3 forum
 
Join Date: Oct 2006
Posts: 618
killer2021 is on a distinguished road
Not working for me either
Reply With Quote
  #5  
Old Nov 12th 2008, 12:41 am
rene7705 rene7705 is offline
Champion of the Naaru
 
Join Date: Oct 2008
Posts: 226
rene7705 is on a distinguished road
Tested in IE and FF;

file t1.html
Code:
<!--compatibility mode-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<body>
<form>
	<input id="details" name="details">
	<input type="button" name="choice" onClick="window.open('t2.html','popuppage','width=850,toolbar=1,resizable=1,scrollbars=yes,height=700,top=100,left=100');" value="Open popup">
</form>
</body>
</html>
file t2.html:
Code:
<!--compatibility mode-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function sendValue (s){
var selvalue = s.value;
window.opener.document.getElementById('details').value = selvalue;
window.close();
}
//  End -->
</script>
<form name="selectform">
<input name="details" value="">
<input type=button value="Copy input to parent opener" onClick="sendValue(this.form.details);">
</form> 

</body>
</html>
Note that if you run this from your local harddrive, IE will likely display an activeX warning. This doesn't happen when you put it on a webserver.
__________________
Rene7705, creator of visCanvasLoaderIcon (free), buttonAnimated (free) and (299 euro/site)
Reply With Quote
  #6  
Old Dec 8th 2008, 2:37 pm
Varsys Inc. Varsys Inc. is offline
Grunt
 
Join Date: Jul 2008
Location: Chicago, IL
Posts: 51
Varsys Inc. is on a distinguished road
That works. Thanks for helpful info.
Reply With Quote
  #7  
Old Jan 14th 2009, 9:29 am
chxxangie chxxangie is offline
Grunt
 
Join Date: Sep 2007
Posts: 54
chxxangie is on a distinguished road
how to get the pop window value to the frame in parent window?
thanks in advance...
Reply With Quote
  #8  
Old Feb 11th 2009, 2:32 am
baybossplaya baybossplaya is offline
Twilight Vanquisher
 
Join Date: Aug 2007
Posts: 595
baybossplaya is on a distinguished road
Code:
<!--compatibility mode-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function sendValue (s){
var selvalue = s.value;
window.opener.document.getElementById('details').value = selvalue;
window.close();
}
//  End -->
</script>
<form name="selectform">
<input name="details" value="">
<input type=button value="Copy input to parent opener" onClick="sendValue(this.form.details);">
</form> 

</body>
</html>
__________________
pinay celebrities pinay bold stars
Reply With Quote
  #9  
Old May 3rd 2009, 1:57 am
mudassar anwar mudassar anwar is offline
Twilight Vanquisher
 
Join Date: Mar 2007
Posts: 600
mudassar anwar will become famous soon enough
is this code still work?
Reply With Quote
  #10  
Old May 28th 2009, 5:14 am
yantomulia yantomulia is offline
Grunt
 
Join Date: Jun 2008
Posts: 58
yantomulia is on a distinguished road
very old thread, is it still work?
__________________
I have Free ebooks website and get style with Indonesian Busana Muslim
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-sizing pop-up window? digitalpoint JavaScript 9 Nov 11th 2008 5:03 pm
Accessing a element of parent window in child window livehed Programming 0 Jun 28th 2005 7:49 am
New Window justtara AdSense 14 Mar 26th 2005 12:04 pm
Passing hidden variables using the get method david_sakh PHP 5 Jan 9th 2005 9:08 pm
Making a pop up(with close window button) ginostylz JavaScript 10 Sep 8th 2004 7:06 pm


All times are GMT -8. The time now is 10:14 am.