Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Data from one window input into a form in another.
Old 12-10-2007, 07:53 PM Data from one window input into a form in another.
feraira's Avatar
BeTheBand!

Posts: 339
Trades: 0
Hi guys. I'm having a bit of confusion on how I can take a value from one (popped up) window and insert it into a form in another window (the winow where the popup came from).

Here is my code at the moment:

<script type="text/javascript">
<!--
function sendText(e, text)
{
e.value = text
}
</script>

$query = safe_query("SELECT * FROM `table` ORDER BY `manager_name` ASC ");
while($p=mysql_fetch_array($query)) {
$user = $p['manager_name'];
$id = $p['id'];

echo "<p><a href='' title='' onclick='sendText(document.sendmoney_form.to, '$user')'>$user</a></p>";

}

The form is called "sendmoney_form" and the field I want it in is called "to". I'm also trying to make it so that the window will close once a value has been entered into the form field.

Thanks.
feraira is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-10-2007, 08:16 PM Re: Data from one window input into a form in another.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
If you opened the second window via window.open try referencing the original window as window.opener
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 12-11-2007, 09:22 AM Re: Data from one window input into a form in another.
feraira's Avatar
BeTheBand!

Posts: 339
Trades: 0
Quote:
Originally Posted by vangogh View Post
If you opened the second window via window.open try referencing the original window as window.opener
I have tried that, it doesn't insert the value into the form.

Live example: www.betheband.org/sendmoney.php

Last edited by feraira; 12-11-2007 at 09:30 AM..
feraira is offline
Reply With Quote
View Public Profile
 
Old 12-11-2007, 07:36 PM Re: Data from one window input into a form in another.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I'm not sure I'm entirely following which page is which and what code goes where. The link to sendmoney.php is that the original window or the popup window?

The code you have in your first post above is that on the original page or on the popup window?

Could you post the code from both pages?
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 12-11-2007, 11:34 PM Re: Data from one window input into a form in another.
feraira's Avatar
BeTheBand!

Posts: 339
Trades: 0
Sorry. My bad.

sendmoney.php

head:
Code:
<script type="text/javascript">
	<!--
	function AddressBook() {
		window.open( "./quickcontacts.php", "AddressBook", "status = 1, height = 300, width = 300, resizable = 0, scrollbars = 1" )
	}
	
	//-->
</script>

body:

Code:
<input type="text" name="to" value="<?php echo $_POST['to']; ?>" /> * [ <a href="#" title="Address Book" onclick="AddressBook()">Address Book</a> ] Who you're sending money to.

quickcontacts.php

head:
Code:
<script type="text/javascript">
	<!--
		function sendText(e, text)
		{
			e.value = text;
			window.close();
		} 
	
	//-->
</script>

body:
Code:
echo "<p><a href='' title='' onclick='sendText(window.opener.sendmoney_form.to, '$user')'>$user</a></p>";


click on address book and a popup will display the names in your address book. click the name and their name will go into the field "to" in the sendmoney file.

Last edited by feraira; 12-11-2007 at 11:36 PM..
feraira is offline
Reply With Quote
View Public Profile
 
Old 12-12-2007, 06:57 PM Re: Data from one window input into a form in another.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I understand now. This is a bit of a guess on my part, but you're setting the value of sendmoney_form.to with javascript and then trying to access it via PHP's $_POST array. I wouldn't think it would be in that array since you haven't passed it back to the original window with php.

You should be able to reference the value in sendmoney.php directly through sendmoney_form.to
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 12-12-2007, 11:44 PM Re: Data from one window input into a form in another.
feraira's Avatar
BeTheBand!

Posts: 339
Trades: 0
The value is already parsed in the contacts (the popup). The only thing that goes to the sendmoney.php FORM is a string of text.

As I said before, if the javascript code to add the value into the form field is on the same window (file / page) it'll work. If not (eg. popup) it won't.
feraira is offline
Reply With Quote
View Public Profile
 
Old 12-13-2007, 08:26 PM Re: Data from one window input into a form in another.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I guess I'm confused then. What I said above seems like it's the issue to me and I'm drawing a blank.

Are you able to access the value of sendmoney_form.to as a javascript value on the original page? Will document.write(sendmoney_form.to) show the correct value?
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 12-14-2007, 07:55 AM Re: Data from one window input into a form in another.
feraira's Avatar
BeTheBand!

Posts: 339
Trades: 0
I have fixed it.

Popup (sendmoney.php):

Code:
<a href="javascript:;" onclick="MM_openBrWindow('quickcontacts.php','','status = 1, height = 300, width = 300, resizable = 0, scrollbars = 1')">Address Book</a> ]
The popup (quickcontacts.php):
Code:
<p><a href="javascript:;" onClick="opener.location.href='sendmoney.php?who=<?php echo "$user"; ?>';window.close();" target="_parent"><?php echo "$user"; ?></a>
Javascript:

Code:
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

Last edited by feraira; 12-14-2007 at 08:02 AM..
feraira is offline
Reply With Quote
View Public Profile
 
Old 12-17-2007, 11:01 PM Re: Data from one window input into a form in another.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
That makes sense. You're sending the URL with a get instead of a post now.

Glad you got it all working. Sorry I couldn't help more.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Data from one window input into a form in another.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31428 seconds with 12 queries