kevinritt Posted February 1, 2009 Share Posted February 1, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/143353-im-really-desparate-or-really-stupid-please-help/ Share on other sites More sharing options...
Snart Posted February 1, 2009 Share Posted February 1, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/143353-im-really-desparate-or-really-stupid-please-help/#findComment-751875 Share on other sites More sharing options...
kevinritt Posted February 1, 2009 Author Share Posted February 1, 2009 the calendar2.php page is an include. Should I still add those html elements? Quote Link to comment https://forums.phpfreaks.com/topic/143353-im-really-desparate-or-really-stupid-please-help/#findComment-752050 Share on other sites More sharing options...
Philip Posted February 1, 2009 Share Posted February 1, 2009 Resource interpreted as script but transferred with MIME type text/html. Take a look at: http://www.lynnarts.org/about_us/admin/includes/bbcode.js I think you'll see the problem why (404) Quote Link to comment https://forums.phpfreaks.com/topic/143353-im-really-desparate-or-really-stupid-please-help/#findComment-752054 Share on other sites More sharing options...
kevinritt Posted February 1, 2009 Author Share Posted February 1, 2009 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 ) Quote Link to comment https://forums.phpfreaks.com/topic/143353-im-really-desparate-or-really-stupid-please-help/#findComment-752056 Share on other sites More sharing options...
kevinritt Posted February 1, 2009 Author Share Posted February 1, 2009 bbcode is here http://www.lynnarts.org/admin/includes/bbcode.js Quote Link to comment https://forums.phpfreaks.com/topic/143353-im-really-desparate-or-really-stupid-please-help/#findComment-752059 Share on other sites More sharing options...
kevinritt Posted February 1, 2009 Author Share Posted February 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/143353-im-really-desparate-or-really-stupid-please-help/#findComment-752063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.