sendafriend.js (+KH)
Code: Select all
window.addEvent('domready', function() {
var sendafriend = $('sendafriend');
if(sendafriend) {
// do not hide send-a-friend form
// if( $('safsuccess') || $('saferror') ) {
if( $('safsuccess') || $('saferror') || $('safok') ) { // +KH: id safok used in "on success"
sendafriend.setStyle('display', ''); // +KH
var sendafriend_status = true;
} else {
var sendafriend_status = false;
sendafriend.setStyle('display', 'none');
}
$('safbutton').addEvent('click', function(r) {
if(sendafriend_status == true) {
sendafriend.setStyle('display', 'none');
sendafriend_status = false;
} else {
sendafriend.setStyle('display', '');
sendafriend_status = true;
}
});
}
});
HTML CP: <div id="sendafriend" class="sendafriend" style="display:none">
FORM CP
HTML CP: </div>
Second advantage: The form is not automatically visible if JS is turned off.
---------
If you need a close link in form:
on success (at the end):
Code: Select all
<p id="safok">The recommendation has been sent successfully.</p>
<br />
[PHP]
echo '<a href="index.php?'.$GLOBALS['content']['struct'][$GLOBALS['content']['cat_id']]['acat_alias'].'">Close form</a>';
[/PHP]
Form template at the end (presupposes Standard tags assembled):
Code: Select all
<br />
<a href="index.php?{CATEGORY_ALIAS}">Close form</a>