Current location: Hot Scripts Forums » General Web Coding » JavaScript » Sending private message with Address Book


Sending private message with Address Book

Reply
  #1 (permalink)  
Old 09-12-06, 03:08 PM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
Sending private message with Address Book

I have a PHP script to send private messages. I have the following fileds on page:

Code:
To:
Subject:
Message: 

[Submit button]
I need to fill each field. When i want to send the message to more users I need to write something like : user1,user2,user3 in "To" field. Each user name separated with ,

I have a link on message sending page called "Insert addresses" when I click on link I see a new window. I create this window with following JavaScript code:

Code:
window.open("address.php?do=addressbook","","width=400,height=300,status=1,resizable=1")
This window show all users from address book. I select more users, using checkboxes.

For example, I need users: user1,user2 from address, I check this users and click on Submit button.

Now I want to close the window and put the string user1,user2 in "to" field.
I don't know what I need to do to put the string in "To" field.

Any suggestions ?

Thanks !
Reply With Quote
  #2 (permalink)  
Old 09-12-06, 03:19 PM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
what if you had the users you selected put into a empty variable and than for the to: section had something like <? $_GET['theusers']; ?>
just a thought
like this
Code:
<form>
<input type="checkbox" name="x" value="<?php . $PHP_SELF . ","?>
<input type="checkbox" name="y" value="<?php . $PHP_SELF . ","?>
</form>
__________________
learning like everyone else

Last edited by pkcidstudio; 09-12-06 at 03:23 PM.
Reply With Quote
  #3 (permalink)  
Old 09-13-06, 01:46 AM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
I need to send the Javascript window ouput to input field ?
Exist a Javascript code or function to do this ?

Anyone help me a bit?

Last edited by zoliky; 09-13-06 at 02:08 AM.
Reply With Quote
  #4 (permalink)  
Old 09-13-06, 02:10 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
You can make the usernames from the address book clickable, and when you click on it the name passes yo the recipients field in the main window. That would be Javascript though. Want me to move this?
Reply With Quote
  #5 (permalink)  
Old 09-13-06, 02:17 AM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
That would be Javascript though. Want me to move this?
Ok, move this thread to JavaScript
Reply With Quote
  #6 (permalink)  
Old 09-13-06, 02:33 AM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
I need something like: http://zulumonkey.org/?id=tutorials&page=comment&oid=88

But I have the input field on other page.
Tha Javascript window and HTML page with input field is two separate file.

Exist a way to send the data with JavaScript to other page?

thanks !
Reply With Quote
  #7 (permalink)  
Old 09-13-06, 03:05 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
Okay, moved.

And try this.
Code:
<script type="text/javascript">

function add_recipient(name)
{
	var target = window.opener.document.getElementById('recipients');
	
	if (target.value == '')
	{
		target.value = name;
		return false;
	}
	
	var recipients = target.value.split(/\,\s?/);
	recipients.push(name);
	recipients.sort();

	target.value = recipients.join(', ');
	
	return false;
}
	
</script>
Code:
<a href="#" onclick="return add_recipient('name');">Add</a>
Place this in the address book window, and change the field id in bold if necessary.
Reply With Quote
  #8 (permalink)  
Old 09-13-06, 03:45 AM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
thanks nico_swd, but I find a simpler example, here: http://www.webmasterworld.com/forum88/436.htm

my code use something like:

Code:
function doSubmit()
{
var myparent = self.opener;

myparent.document.foo.to.value='Testing';
}
I need to replace the Testing with an implode value.. Something like user1,user2,user3...

Is hard to do this ?

Thanks !
Reply With Quote
  #9 (permalink)  
Old 09-13-06, 03:52 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
The most simple thing you can do is:

Code:
function add_recipient(name)
{
     window.opener.document.getElementById('recipients').value += ', '+ name;
     return false;
}
Code:
<a href="#" onclick="return add_recipient('some name');">Add</a>
Reply With Quote
  #10 (permalink)  
Old 09-13-06, 03:59 AM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
I select the users that I want to add to input field with something like :

http://www.mredkj.com/tutorials/tutorial_mixed2b.html

When I click submit I get something: user1,user2,user3.

Code:
if (isset($_POST['submit']))
{
   $implode = implode(",", $select2);
   print $implode;    // user1,user2,user3
}
I need to send this data to Javascript, the implode output

Thanks !
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
Needed to modify a Hotmail Address Book Importer FireStorm~ PHP 4 02-11-11 11:26 AM
need address book suggestion jmyers1643 Script Requests 3 09-07-06 11:30 AM
Import yahoo, msn, Gmail address book for particular yahoo, msn, Gmail Email Id srini_r_r PHP 1 07-20-06 02:52 AM
Copy body text into form text box simon@edgehillcu JavaScript 11 03-30-06 04:53 AM


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