Jump to content

Recommended Posts

Hi Guys, I was wondering if you could give me a bit of help. I have a e-mail list that I would like to be able to select witch user is going to be e-mailed, also it would have the check all / uncheck all buttons. I have an none working example of what I need to code here:

 

http://bbold.com/strataman/admin.php

 

Here is what I got so far.

 

<!-- Includes Header start -->

<?php include('includes/header.php'); ?>

<!-- Includes Header Ends / Content Starts -->
		<h1>E-mail Subscribers:</h1><br />
<div id="listings">
		<center><h3>Mailing List</h3></center>

		<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
//  End -->




</script>

		<?php
			// Connect to DataBase
			include 'includes/dbconnect.php';


				// Query database
				$query = "SELECT * FROM mail";
				$rs = mysql_query($query);
					echo 'Subscription List <br /><br />';
					echo "<form name=\"myform\" action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">" . "<br />";
						while($row = mysql_fetch_array($rs))
							{
								echo "<input type=\"checkbox\" name=\"list\" value=\"" .$row['email']. "\" >" . " <a href=\"mailto:" . $row['email'] . "\">" . $row['email'] . "</a><br />";
							}	

// If summit button clicked do this!!
if($_POST['submit'])
	{

		echo $_POST['list'];

	}


		?>

<br />
<input type="button" name="CheckAll" value="Check All"
onClick="checkAll(document.myform.list)">
<input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.myform.list)">
<br/>
Send an e-mail:<br />
<textarea name="message" rows="10" cols="100"></textarea><br/><br />
<input type="submit" name="submit" value="Send">

<br /><br />

Attach a file:<br />
<input type="file" name="file">





</form>




</div>

<!-- Includes Footer Starts -->

<?php include('includes/footer.php'); ?>	

<!-- Includes Footer Ends -->

Link to comment
https://forums.phpfreaks.com/topic/74616-checkbutton-e-mail-list-with-check-all/
Share on other sites

Oh ok, Thanks, that works good, Now I just have one more problem.

 

Since you changed the last name, my javascript for the check all isn't working. I'll post the code...

 

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
//  End -->




</script>

		<?php
			// Connect to DataBase
			include 'includes/dbconnect.php';


				// Query database
				$query = "SELECT * FROM mail";
				$rs = mysql_query($query);
					echo 'Subscription List <br /><br />';
					echo "<form name=\"myform\" action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">" . "<br />";
						while($row = mysql_fetch_array($rs))
							{
								echo "<input type=\"checkbox\" name=\"list[]\" value=\"" .$row['email']. "\" >" . " <a href=\"mailto:" . $row['email'] . "\">" . $row['email'] . "</a><br />";
							}	

// If summit button clicked do this!!
if($_POST['submit'])
	{

		foreach($_POST['list'] AS $email){ 
		echo $email;
		}
	}


		?>

<br />
<input type="button" name="CheckAll" value="Check All"
onClick="checkAll(document.myform.list)">
<input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.myform.list)">
<br/>
Send an e-mail:<br />
<textarea name="message" rows="10" cols="100"></textarea><br/><br />
<input type="submit" name="submit" value="Send">

 

I think it's just this part thats messing it up

 

<input type="button" name="CheckAll" value="Check All"
onClick="checkAll(document.myform.list)">
<input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.myform.list)">

 

I already tried changing the (document.myform.list) to (document.myform.list[]). Any other suggestions?

Thanks for your help so far.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.