Current location: Hot Scripts Forums » General Web Coding » JavaScript » How to send value of textbox input to popup window ?


How to send value of textbox input to popup window ?

Reply
  #1 (permalink)  
Old 06-13-08, 01:39 AM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
How to send value of textbox input to popup window ?

Hi all i got a textbox and i allow the user enter some value and hit the submit. On submit i want that value be passed to javascript and that javascript opens a popup window along with that value. I have done most of the part only don't know how to pass value of text box to javascript on click of submit. I be happy if some one help with it.


Note : i don' want the form get redirected to new page !!


HTML Code:
<form method="POST" action="--WEBBOT-SELF--">
  
  <input type="text" name="T1" size="20"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

Code:
<script language="javascript">


function newWindow(url) { 
	var x,y;
	x = screen.width-35;
	y = screen.height-30;
	var win = window.open(url,'glossaryWindow','toolbar=no,directories=no,width=500,height=500'+
	'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');
}  

// Start of Playme Function
function playme()
{
tempUrl ='';
url = '';


	//alert(tempUrl);
	url = "./player.php?songid=" + tempUrl.replace(/,$/,"");

	newWindow(url);
	return false;
}		
// End of Playme Function	
// -->	
</script>
Reply With Quote
  #2 (permalink)  
Old 06-13-08, 03:11 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Reply With Quote
  #3 (permalink)  
Old 06-13-08, 11:21 AM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks nico for pointing me to that link. But that example doesn't show me how to pass the inserted value to that popup window Just like popupwindow.php?value=23232
Reply With Quote
  #4 (permalink)  
Old 06-13-08, 06:44 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
If you wish to interact directly with the new window, you can do so through the reference returned by window.open(). In this case the win variable.
If you put
JavaScript Code:
  1. win.myVarA = "Hello";
in the newWindow method, there will be a global variable named myVarA with the value "Hello" in the scope of the new window, and you can use it as any other variable inside that window.

Of course, you can also interact with the new window from the opener window by making the win variable global, as it's now going out of scope right after the window was created and it's tricky to get it back, if it can be done.

You're a bit unspecific about what you want to do with the value once it's in the new window, and exactly which value you wish to pass, so I'm not sure what you want. Any extra info you can specify makes it easier to find a suitable solution .
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #5 (permalink)  
Old 06-17-08, 02:21 PM
mariowowo mariowowo is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Also can do this from newWindow:

JavaScript Code:
  1. <script>
  2. function test()
  3. {
  4. document.[FormName].[newWindowTextBoxName].value=window.opener.document.GetElementByID('textboxID').value
  5. </script>
And:
HTML Code:
<body onload="javascript:test();">

think that works...

Last edited by TwoD; 06-17-08 at 04:15 PM. Reason: Please remember [highlight=JavaScript][/highlight] etc...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
a.c. 50Hz voltage asm trouble steph6 Other Languages 0 04-09-08 05:17 AM
Send file names to parent window hidden input fields zoliky JavaScript 14 09-28-06 04:20 AM
creating a popup window? chrisrobertson JavaScript 1 08-18-06 11:37 AM
Replace Popup Window? aDcOoL Script Requests 2 03-04-06 04:48 PM
how do I update form, and hidden values in a form from a popup window? lordmerlin JavaScript 2 12-13-05 02:05 PM


All times are GMT -5. The time now is 11:38 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.