I'm a little out of my depth in server-side scripting, so I have to ask for some help here.

I had some great help yesterday getting a 'select-all' checkbox script working, but have run up against a wall on the next step.

Here's what I want to do, it relates to member services for a volunteer service club.

Currently, I have an 'electronic post office' form that retrieves from the database a list of names and emails for the current membership and creates a form where they can cut and paste the address list or click a mailto link.

Here's the code, please use it for your own projects if it seems useful (I've removed some bits specific to my application);

<!--~~~~~~ BUILD THE FORM FOR THE GENERAL MEMBERSHIP LIST ~~~~~~~~~~~~~~~~~~~~~~~~-->
// generate list of all names and email addresses for current members
$dataset_all = mysql_query("
SELECT id,firstname,lastname,email
FROM members 
WHERE status = 'current' 
ORDER BY lastname,firstname

// initialize this variable in which the list code will be built
$list 		= "";

// estimate # of rows needed for textearea
$addressrows  = (mysql_num_rows($dataset_all) / 2)+1;

// now loop through the records, cleaning up the data and building the list
while ($thisrow = mysql_fetch_array($dataset_all)) {

	// create a variable for each attribute
	foreach($thisrow as $var => $value){
		$$var = $value;

	// capture and clean data from this record
	$email	= trim($email);
	$name 	= "$firstname $lastname";

	// append this name/address to the list
	if ($thisrow["email"]) {
		$list .= " $name <$email>; ";

// a last bit of clean up on the list
$list  = trim($list);      // trim whitespace
$list  = rtrim($list,";"); // trim trailing semicolon
$list .= "\n";       // add a linefeed to facilitate cut and paste

// the list is now ready to be used in the form below.
<form name="form_current">
  <div style="border:1px solid tan;padding:10px;margin-bottom:15px;background-color:#fdf5e6;">
    <span style="color:maroon;font-weight:bold;">General Membership</span> (Contains primary eMail addresses of all current members.)
    <p><A href="mailto:<?php echo "$list"; ?>"><span style="font-weight:bold;border:1px solid tan;padding:0px 10px;margin-top:6px;background-color:#ffffff">Click here</span></a>
     to open a message form with the addresses filled in.  With some email programs, you will need to copy the address list from the box below.</p>
    <textarea id="holdtext" name="select1" cols="100" rows="<?php echo "$addressrows"; ?>" class="textarea" style="font-size:80%;font-weight:normal;padding:10px;">
      <?php echo "$list"; ?>
<!--~~~~~ /build the form for the general membership list ~~~~~~~~~~~~~~~~~~~~~~~~-->

What I want to do now is generate from the database a list of checkboxes for all my members. The objective is to let the user check those members they want to send a message to. I have the list of checkboxes generated and working.

Now I need some help. I see two ways to proceed here.

1) I can use a textbox and mailto: link as I did in the example above, and find some way that the textbox and mailto link will dynamically update as the user selects and de-selects names in the list. I think it's possible to change the textarea dynamically, not so sure about the mailto link. This is by far the preferred method, but I'm not sure how to proceed.

2) I can create a popup window with a form as in the example above. The first problem I can see with that is that a popup window seems to want to have an existing page, where my content would be transient, existing only in real-time and disappearing when the user closes the window.

Can anyone guide me to a solution here?

While I wait I'm going to mosey on over to the PHP forum, where I'm more comfortable, and see if can pay it forward with some help for someone else over there.


Edited by scaiferw: n/a

7 Years
Discussion Span
Last Post by scaiferw

I should add that I'm sure that jQuery/AJAX could do this quite handily, but I haven't the foggiest notion of how to go about it, and the thought of trying to get current on those topics any time in the next few months makes my head hurt.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.