Jump to content

Recommended Posts

I have a page which can be edited here http://www.lynnarts.org/about_us/calendar2.php?action=editcalendar_content&edit=edit&calendarId=1. I am using bbcode but it does not work. I looked at FF addon called console and it tells me that the bbcode is not defined. I don't know what that means. Here's the bbcode.js

function bbcode(open, end){ 
var tArea = document.description.description; 
var isIE = (document.all)? true : false; 
var open = (open)? open : ""; 
var end = (end)? end : ""; 
if(isIE){ 
tArea.focus(); 
var curSelect = document.selection.createRange(); 
if(arguments[2]){ 
curSelect.text = open + arguments[2] + "]" + curSelect.text + end; 
}else{ 
curSelect.text = open + curSelect.text + end; 
} 
}else if(!isIE && typeof tArea.selectionStart != "undefined"){ 
var selStart = tArea.value.substr(0, tArea.selectionStart); 
var selEnd = tArea.value.substr(tArea.selectionEnd, tArea.value.length); 
var curSelection = tArea.value.replace(selStart, '').replace(selEnd, ''); 
if(arguments[2]){ 
tArea.value = selStart + open + arguments[2] + "]" + curSelection + end + selEnd; 
}else{ 
tArea.value = selStart + open + curSelection + end + selEnd; 
} 
}else{ 
tArea.value += (arguments[2])? open + arguments[2] + "]" + end : open + end; 
} 
} 

and php function

function ValidateOutput($value) {
	$BBCode = array(
	"
[center]" => "<center>", "[/center]
" => "</center>", 
	"[b]" => "<b>", "[/b]" => "</b>", 
	"[u]" => "<u>", "[/u]" => "</u>",
	"[i]" => "<i>", "[/i]" => "</i>",
	"[*]" => "<li>", "" => "</li>",
	"[font]" => "<font>", "[font]" =>"</font>",
	); 
	$value = str_replace(array_keys($BBCode), array_values($BBCode), $value); 
	$value = stripslashes(nl2br($value));
	return $value; 
}

function buttons() {
	$buttons = '<input type="button" value="Bold" onclick="bbcode(\'[b]\', \'[/b]\')" /> 
	<input type="button" value="Italic" onclick="bbcode(\'[i]\', \'[/i]\')" /> 
	<input type="button" value="Underline" onclick="bbcode(\'[u]\', \'[/u]\')" />
	<input type="button" value="List Item" onclick="bbcode(\'[*]\', \'\')" />';
	return($buttons);
}

and here's the form

echo '<form name="description" method="post" action="'.$_SERVER['PHP_SELF'].'?action=editcalendar_content">
  	<table class="clustertable" width="550" align="center" cellpadding="4" cellspacing="1">
    <tr> 
    <td colspan="2" align="center"><b>Edit calendar content</b></td>
    </tr>
    <tr> 
    <td colspan="2"> </td>
    </tr>
<tr> 
    <td colspan="2" align="center">'.$error_msg.'</td>
    </tr>

  <tr>
    <td align="center">'.buttons().'<br />
<textarea name="description" cols="85" rows="35">'.$calendar_content.'</textarea></td>
    </tr>

<tr>
    <td class="clustertd" colspan="3" align="center">
<input name="edit" type="hidden" value="'.$_REQUEST['edit'].'" />
<input name="newsid" type="hidden" value="'.$_REQUEST['calendarId'].'" />
    <input type="submit" name="Submit" value="Submit">
</td>
    </tr>
  	</table>
</form>';

Can anyone help?

You're not linking your javascript page (bbcode.js) to the page that contains the form, so it doesn't know bbcode().  In fact, you're not using any kind of basic HTML at all (<HTML><HEAD><TITLE>...)

 

Try adding this to your form page:

 

<html>

<head>

  <title>Calendar</title>

  <script language='javascript' src='bbcode.js'></script>

</head>

<body>

  Replace this text by your form

</body>

</html>

ok - I got the bbcode to work in the text area but when I 'submit' and view the changed page the bbcode has no effect. Basically, I want something like what I'm using for this post. Any thoughts? (I'm almost there  :P)

If I enter the bbcode, [ b ] some text [ /b ] for example, manually in the database using PHPMyAdmin, it shows on the post. If I enter it online using the form, the bbcode looks like it works but when I update the database it doesn't carry over to the post

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.