/    Sign up×
Community /Pin to ProfileBookmark

select boxes POST

I have a select box that gets filled from a DB query and contains a list of email addresses. I allow the user to multi select email addresses and by way of javascript move the selected email addresses over to another select box.

Now once they have their selected group of email addresses in the second box they hit submit and I process these email addresses. This is what I want.

So how do I access these email addresses on the next page? I need all of the addresses from the second box that they moved over. I am using php on the server side and using the post method on the form.

Thank you for your time.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@tripwaterauthorApr 01.2003 — I assume I just loop through the count of objects and set each to selected?

Once that happens do I access the array through POST_VARS on the next page?
Copy linkTweet thisAlerts:
@tripwaterauthorApr 01.2003 — I am new to Javascript and I think I am going to need some help with that function to loop through the select box I tried what I thought would work in the function call White() below is my code . There is php and mysql mixed in so ignore that.

Thanks ahead of time.



<script LANGUAGE="JavaScript">



<!--// -------------------------------------------------------------------
// copySelectedOptions(select_object,select_object[,autosort(true/false)])
// This function copies options between select boxes instead of
// moving items. Duplicates in the target list are not allowed.
// ------------------------------------------------------------------->
function copySelectedOptions(from,to)
{
var options = new Object();
for (var i=0; i<to.options.length; i++)
{
options[to.options[i].value] = to.options[i].text;
}
for (var i=0; i<from.options.length; i++)
{
var o = from.options[i];
if (o.selected)
{
if (options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text)
{
to.options[to.options.length] = new Option( o.text, o.value, false, false);
}
}
}
if ((arguments.length<3) || (arguments[2]==true))
{
sortSelect(to);
}
from.selectedIndex = -1;
to.selectedIndex = -1;
}




<!--// -------------------------------------------------------------------
// removeSelectedOptions(select_object)
// Remove all selected options from a list
// (Thanks to Gene Ninestein)
// ------------------------------------------------------------------->
function removeSelectedOptions(from)
{
for (var i=(from.options.length-1); i>=0; i--)
{
var o=from.options[i];
if (o.selected)
{
from.options[i] = null;
}
}
from.selectedIndex = -1;
}



function White(line)
{
for (var j=0; j > (from.options.length); j++)
{
line[j].selected = true;
}
}


</script>








<!--***************************************END OF JS Functions****************************-->









<form name=vblocked method="POST" action="../admin/clearblocked.php" onSubmit="return White(document.forms[0].towhite)">
<table cellpadding=3 cellspacing=5 border=0>
<tr>
<td>
All of the email addresses below have been sent an email
of rejection that they must reply to for proof of legitimacy.
Once they reply they will be added to SpamnIt's Database and
be able to send you email. If you know someone in the list is
legitimate or see a newsgroup/forum address,
<b><a href=../admin/adminwhite.php>Click here</a></b> to add them to your
Whitelist so you can immediately receive email from them.
</td>
</tr>
<tr>
<td>
SpamnIt periodically cleans out these declined emails. If you would like
to clear them sooner, check the <b>delete</b> box and click <b>Submit</b>
to clear all declined email addresses from your list.<p>
</td>
</tr>
</table>

<table cellpadding=3 cellspacing=5 border=1>
<tr>
<td>
<b>Email Address</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Date Declined</b>
</td>
</tr>
<tr>
<td width=20>
<select multiple name=blocked size=15>";

//here we loop through our query results and build the list of
//blocked email addresses and dates they were blocked.
while ($row = @mysql_fetch_array($result))
{
//here we query the declined table inside this loop for each address
//to see if they are still in there meaning they have not
//replied to the email that was sent to them. We do this
//so we can display a different row color to the user to
//show who has replied after being blocked and who has not.
$query = "select UserID from declined where EmailFrom ='".$row[1]."'";

$result2 = @mysql_query($query);

$row1 = @mysql_fetch_array($result2);

if (!empty($row1[0]))
{
$value .='<Option style=color:red>'.$row[1]."&nbsp;&nbsp;&nbsp;".$row[2];
}
else
{
$value .='<Option>'.$row[1]."&nbsp;&nbsp;&nbsp;".$row[2];
}
}


//here we run a query to count the total of declined emails for a user a display
//them.
$query = "select count(*) from blockedemails where UserID = ".$HTTP_SESSION_VARS["uid"];

$result = mysql_query($query);

$row = mysql_fetch_array($result);

$value .= "</select>
</td>
<td>
<a HREF="#" onClick="copySelectedOptions(document.forms[0].blocked,document.forms[0].towhite,false);return false;">Move to Whitelist&gt;&gt;</a><br><br>
</td>
<td>
<select NAME="towhite" MULTIPLE size=15>
<option value="">
</select><br>
<a HREF="#" onClick="removeSelectedOptions(document.forms[0].towhite); return false;">Remove Selected Options</a>
</td>
</tr>
<tr>
<td colspan=3>
<span style=color:red>Emails in Red have not replied to the confirm email.</span>
</td>
</tr>
<tr>
<td>
<b>Total Declined = ".$row[0]."</b>
</td>
<td>
<b>Clear Declined List <input type=checkbox name="clear">&nbsp;&nbsp;&nbsp;<input type="submit" name="submit" value=Submit>
</td>
</tr>
</table></form>
<p><b><a href=../main/acctmain.php>Return to main account menu</a></b>";


}
Copy linkTweet thisAlerts:
@tripwaterauthorApr 01.2003 — Hello? did I ask a stupid question? Where did eveyone go?
Copy linkTweet thisAlerts:
@tripwaterauthorApr 02.2003 — Thanks for the reply and the direction. I am having the same problem that Lily was as when I manually select all of the addresses in the list and hit submit just to see what is passed over (I am using php server side) my POST_VARS ,which handles form elements as posted variables to the next page, only echos one email address even after I have manually selected all of them on the previous page. I also tried this on the submit page :

$temp = explode("n",$HTTP_POST_VARS["towhite"]);

foreach ($temp as $value)
{
echo $value;
}


"towhite" is my editbox name.

someone suggested I try this to explode the new line character and set the remaining element into an array and echo the results. This resulted in the same...one email address.

I understand everything needs to be selected in the list but my problem is php has a function called print_r(get_defined_vars()); which prints all defined and set variables to the screen and in which I can search for what is holding this comma separated array but after manually selecting and submitting...again I can only find one email address in the list. I do not know what to do. I have this question in a php forum as well and so far no good.

Thank you again for your time.
×

Success!

Help @tripwater spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...