Ckeditor did not work for me? - php

I want use ckeditor 4.3.4 to codeigniter 2.1.4 i tried to start testing it in jsbin, it did not work.what do i do?
How can you use ckeditor 4.3.4 in codeigniter 2.1.4?
How can install ckeditor basic?
DEMO: http://jsbin.com/lacekiyu/1/edit
Code:
<html>
<head>
<script src="www.ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
<script>
CKEDITOR.replace( 'editor1' );
</script>
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
</form>
</body>
</html>

1). Change your ckeditor js link to correct url: http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js.
2). Add body onload event, and it will work.
<html>
<head>
<script src="http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
<script>
function init() {
CKEDITOR.replace( 'editor1' );
}
</script>
</head>
<body onload="init()">
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
</form>
</body>
</html>

You need to correct the reference to the CKEditor script and add the CSS class ckeditor to the textarea.
<head>
<script src="http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
</head>
<body>
<form>
<textarea class="ckeditor" name="editor">
This is my textarea to be replaced with CKEditor.
</textarea>
</form>
</body>
You could host the CKEditor JavaScript on your server. Assuming it is stored in a folder in your web root, called assets (e.g. public_html/assets) and the URL helper is loaded, you can reference it in a view:
<script src="<?php echo base_url("assets/ckeeditor.js"); ?>"></script>

Related

The usage of TinyMCE 4.1.4 in php page

I'm trying to use TinyMCE 4.1.4 in my php page but I didn't succeed, I did include the path of TinyMCE but when I execute the script it gives me simple text area, I don't know what's the problem.
<html>
<head>
<script type="text/javascript" src="js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea"
});
</script>
</head>
<body>
<form method="post">
<textarea ></textarea>
</form>
</body>
</html>
Works fine here jsFiddle Demo
Try to include your code inside ready function before that include jQuery library as well so your full code should be :
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
tinymce.init({
selector: "textarea"
});
});
</script>
</head>
<body>
<form method="post">
<textarea ></textarea>
</form>
</body>
</html>
It's because you're doing all the JS before the DOM has fully loaded.
<body>
<form method="post">
<textarea ></textarea>
</form>
<script type="text/javascript" src="js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea"
});
</script>
</body>
</html>

TinyMCE Jquery not working fine

Hi I had used TinyMCE in my code single page code to upload data into server using TinyMCE. My Code is as follows, this is the add.php page :
<?php
$msg="";
include("config.php");
if($_POST['title']!= ""){
$title= $_POST['title'];
$words= $_POST['words'];
$words= stripslashes($words);
if (!$title)
{
$msg="Please Enter Title";
} elseif (!$words)
{
$msg="Please enter the Blog";
}
$query= mysql_query("INSERT INTO editor (title, content) VALUES ($title, $words)") or die (mysql_error());
$msg="Success!";
}
?>
<! DOCTYPE html>
<html>
<head>
<title>Add New Blog</title>
<script type="text/javascript" src="jquery-1.11.0"></script>
<script type="text/javascript" src="tinymce.min"></script>
<script type="text/javascript" src="jquery.tinymce.min"></script>
</head>
<body>
<div>
<p><b>Add a New Blog</b></p>
<form action="add.php" method="post">
Title of the Blog :
<br/>
<input type="text" name="title"></input>
<br/>
Your Blog :
<br/>
<textarea name="words" class="tinymce" cols="30" rows="10"></textarea>
<br/>
<input type="submit" value="submit"/> <?php echo $msg; ?>
</form>
</div>
</body>
</html>
My Textarea is displayed as a normal textarea, the data is also not going into the Database.
The config.php file is for Database connection and it is working fine, I checked it.
Please help, Thanks in advance.
<! DOCTYPE html>
<html>
<head>
<title>Add New Blog</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script>
tinymce.init({
selector: "textarea"
});
</script>
</head>
<body>
<div>
<p><b>Add a New Blog</b></p>
<form action="add.php" method="post">
Title of the Blog :
<br/>
<input type="text" name="title"></input>
<br/>
Your Blog :
<br/>
<textarea name="words" class="tinymce" cols="30" rows="10"></textarea>
<br/>
<input type="submit" value="submit"/> <?php echo $msg; ?>
</form>
</div>
</body>
</html>
You forgot to add extension in linked script file
<script type="text/javascript" src="jquery-1.11.0.js"></script>
<script type="text/javascript" src="tinymce.min.js"></script>
<script type="text/javascript" src="jquery.tinymce.min.js"></script>
Check this Sample Demo
I think you are added two TinyMCE library so it's may be conflict problem. So please update only this two library
I am add only 2 library
JQuery Library - http://code.jquery.com/jquery-1.11.0.min.js
TinyMCE Library - http://tinymce.cachefly.net/4.0/tinymce.min.js
And In your Header add this script
<script>
tinymce.init({
selector: "textarea"
});
</script>
try now its work.

How to use CKEditor as form input?

I am trying to make simple web editor using CKEditor but i cant find out how to make it work.
First i checked their samples site. Only thing they do to make CKEditor work is include .js file and add ckeditor class to form textarea element.
<script src="../ckeditor.js"></script>
.
.
.
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
So i copy .js file and try it in my own folder and when i run php script whole textarea element is hidden and doesnt create CKEditor panel as it should like in this sample page. There might be some javascript configuration but i havent found any in source code of sample page.
call CKEDITOR.replace( 'editor1' ); in your js files or simply in your html file like this:
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
<script>
CKEDITOR.replace( 'editor1' );
</script>
Copy all of your ckeditor folder to server.
Add it to html page ;like this:
<script src="../script/ckeditor/ckeditor.js" type="text/javascript"></script>
Assign CSS class of ckeditor to textarea; like class="ckeditor".
<script src="../ckeditor.js"></script>
<form name="ckeditor">
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
As given in the main website.
<script src="https://cdn.ckeditor.com/ckeditor5/34.2.0/classic/ckeditor.js"></script>
<form method="post">
<textarea name=msg id="editor">Text</textarea>
<input type="submit">
</form>
<script>
ClassicEditor
.create(document.querySelector('#editor'))
.then(editor => { console.log(editor); })
.catch(error => { console.error(error); });
</script>

jQuery .load() function stops me from calling a script in HTML-file

My login.html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="lv">
<head>
<?php require_once 'inc/metahead.php'; ?>
<title>Logg inn</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js">
</script>
<script type="text/Javascript" src="functions.js">
</script>
</head>
<body>
<div id="content">
<center>
<form>
<label for="epost"></label> <input type="text" name="epost" id="epost"
placeholder="Epost/Bruker" /></br> </br> <label
for="passord"></label> <input type="password" name="passord" id="passord"
placeholder="Passord" /></br> </br> <input
type="button" onclick="login()" value="Logg inn">
</form>
<br /> Glemt passord?
</center>
</div>
</body>
</html>
This piece of code is from my header.php file:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function loginNow(){
$(document).ready(function() {
$("#content").load("login.html");
});
}
</script>
If i go directly in login.html - It calls the function without problems. BUT, if I go through my index-file and click "Logg inn", so the script above run, the script in login.html never gets called.
I have tried to alert something out instead of calling my script - That works. Any help would be greatly appreciated!
what i think is you have two jquery files with different version loaded there which is creating the conflict
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js">
in login.html
and other is
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
in header.php
so either you use noConflict().. or remove one of them
The function name is different here
onclick="login()" // you are calling login()
function loginNow(){ // but declaring loginNow()
Your HTML code:
...
<input type="password" name="passord" id="passord"
placeholder="Passord" /></br> </br> <input
type="button" **onclick="login()"** value="Logg inn">
...
Your Javascript Code:
function **loginNow()**{
$(document).ready(function() {
$("#content").load("login.html");
});
}
Check the enclosed parts - Different function names ;)
Don't use onlick="". Since you are using jQuery, hook an event to your input element:
$(document).ready(function(){
$('input[type=button]').click(loginNow);
});
Eventually give the button an id or a name and use this as the selector in jQuery.

AJAX/PHP simple code fails to work

I was following a tutorial to understand how AJAX/PHP works but i'm having an issue.
Let me start with the code.
escalationTest.php:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form>
<input type="text" id="name" placeholder="Enter Name.." /> <br>
<input type="text" id="age" placeholder="Enter Name.." />
<input type="button" value="Submit" onClick="post();" />
</form>
<div id="result"></div>
<script type="text/javascript">
function post()
{
var name= $('#name').val();
var age= $('#age').val();
$.post('escalation.php',{postname:name,postage:age},
function(data)
{
$('#result').html(data);
});
}
</script>
</body>
</html>
escalation.php:
<?php
echo "working";
?>
I've typed the code exactly how its in the tut. From its output when i click the submit button i should "working" in the result div which is not happening.
What am i doing wrong here..?
Thanks.
<script type="text/javascript" src="jquery.min.js"></script>
Download a version of jQuery and then link to it with this script tag.
While you can link to an online version, it's not ideal for eventual production use and you should definitely get a local copy.
add the folowing line to your head tag
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
This is a pretty simple fix - you're missing jQuery. Add the following:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
in your head element.

Categories