Forum Moderators: coopster

Message Too Old, No Replies

Show hide layer in loop

         

music_man

2:01 am on Feb 2, 2006 (gmt 0)

10+ Year Member



Hi

I have looked at tutorials on how to do this, but I am not sure how to implement a javascript show/hide function into this following situation.

The script opens a text file and displays all the results. I am looking to have it able to show and hide each one onClick. The javascript I have been working with uses one id and that isn't very useful for looping.


<?php $page="newsletter"; include ("inc/files/header.php");

#####################
#
# Newsletter signup and show changed 30.1.06
#
#####################
$_POST["email"] = $email;
$number = rand(1000, 9999);
$email_address = stripslashes($_POST['email']);
$email_id = "$number";
$email_id = md5($email_id);
$pipe = "¦";
$cr = "\n";
$data .= $email_address . $pipe . $email_id . $cr;
$confirm_message = "
<b>
Message</b>";
if($_POST["action"] == "send")
{
$fp2 = fopen(SUBSCRIBERSDATA, "r");
$file_text = fread($fp2, 999999);
fclose($fp2);
$subscribers = explode(",",$file_text);
foreach($subscribers as $subscriber)
{
if($subscriber == $_POST["email"])
{
die("
<div id=\"content\">
<h3>
<b>
Sorry
</b>
but you have already been added to the mailing list.
</h3>
</div>
");
}
else
{
$fp = fopen(TMPDATA,"a");
if($fp){
fwrite($fp,$data);
fclose($fp);
}
}
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: email>" . "\r\n";
mail($_POST["email"], Confirmation, $confirm_message, $headers);
$msg = "A confirmation email has been sent out to you. Please check your junk mail filter just in case it doesn't reach you.";
}
?>
<!-- content -->
<?php
if($_POST["action"]!= "send") {?>
<div style="border: 1px solid #ccc; background-color: #eee; padding: 5px; font-family: Arial, sans-serif; font-size: .8em;">
<h3>
<b>
Join our mailing list
</b>
</h3>
<br />
<form name=add action='newsletter.php' method='POST'>
Email address:
<input class=textField type=text name=email>
<input class=button type=submit value=Send>
<input type=hidden name=action value=send>
</form>
<script language=javascript>
var validator = new Validator('add');
validator.addValidation('email','req','Please enter a valid email');
validator.addValidation('email','email','Please enter a valid email');
</script>
<br />By adding your email to the mailing list, you agree to the <a href="termsofservice.php" target="_blank">Terms of Service</a>.
</div>
<?php } else {?>
<div style="border: 1px solid #ccc; background-color: #eee; padding: 5px; font-family: Arial, sans-serif; font-size: .8em;">
<h3>
<?php echo "$msg";?>
</h3>
</div>
<?php }?>
<div id="content">
<h3>
<?php
$userinfo1 = file(NEWSLETTERDATA);
foreach($userinfo1 as $key1 =>
$val1)
{
$data1[$key1] = explode("¦¦", $val1);
}
for($k = 0; $k
< sizeof($userinfo1); $k++)
{
echo '

// Link to show

Date:
<b>
'.$data1[$k][1].'
</b>
<br />
<br />
';
// hidden until the link above is clicked
echo $data1[$k][0];
echo '
<br />
// close button probably
<hr />
';
}
?>
</h3>
</div>
<!-- // content -->
<?php include ("inc/files/footer.php");?>

music_man

6:12 am on Feb 8, 2006 (gmt 0)

10+ Year Member



... bump...

dreamcatcher

9:07 am on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Think this might be better in the javascript forum?