/    Sign up×
Community /Pin to ProfileBookmark

Updating FCKeditor box based on Radio buttons

Hi,

I am trying to populate an FCKeditor box based on selection criteria on the radio buttons. This is only for adding a new session and I want it to be editable later. Currently I have the javascript being built in PHP as it is database driven. I have tried to populate the hidden input box (text) and although the value is populated it doesn’t show in the FCKeditor. Below is the code that I have at the moment.

function trainingHeader(header, text)
{
document.getElementById(“header”).innerHTML = text;”;
$q = mysql_query (“SELECT * FROM calendar_cat WHERE cat_id = 1”);
$row = mysql_fetch_array($q);
$text = addslashes($row[‘descrip’]);
echo “document.getElementById(“text”).value = “{$text}”;
echo “alert (document.getElementById(“text”).value = “{$text}”);

}

Here is the FCKeditor:

$oFCKeditor = new fckeditor(‘text’) ;
$oFCKeditor->BasePath = ‘../core/fckeditor/’;
$oFCKeditor->Value = $_POST[‘text’];
$oFCKeditor->Height = 400;
$oFCKeditor->Create() ;

Forgive me if this is completley the wrong way of going about it – I have very basic knowledge of Javascript but want to learn – so any help is appreciated.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@toicontienJan 25.2008 — $oFCKeditor = new fckeditor('text') ;

$oFCKeditor->BasePath = '../core/fckeditor/';

$oFCKeditor->Value = $_POST['text'];

$oFCKeditor->Height = 400;

$oFCKeditor->Create() ;
[/QUOTE]


If this is JavaScript, the syntax is wrong. Note that it should be:

var oFCKeditor = new fckeditor('text') ;
oFCKeditor.BasePath = '../core/fckeditor/';
oFCKeditor.Value = "<?=$_POST['text']?>";
oFCKeditor.Height = 400;
oFCKeditor.Create() ;

I am completely confused about the trainingHeader function. Is that JavaScript or PHP? From what you wrote, it looks like both.
Copy linkTweet thisAlerts:
@FamilyManauthorJan 25.2008 — The FCKeditor is within a PHP file - so the syntax is correct - the trainingHeader function is both PHP and JavaScript - its the only way that I could get it database driven!
Copy linkTweet thisAlerts:
@toicontienJan 25.2008 — Ok. Then perhaps the trainingHeader function should be written like this?
[code=php]<?php
$q = mysql_query ("SELECT * FROM calendar_cat WHERE cat_id = 1");
$row = mysql_fetch_array($q);
$text = addslashes($row['descrip']);
?>
<script type="text/javascript">
function trainingHeader(header, text)
{
document.getElementById(header).innerHTML = text;
document.getElementById("text").value = "<?=$text?>";
alert(document.getElementById("text").value);
}
</script>[/code]

I'm not sure which part of the trainingHeader function is PHP and which is JavaScript. It seems to be completely mixed. I was expecting <?php ?> tags somewhere. If this is incorrect, I'm going to need to see more of the PHP file.
×

Success!

Help @FamilyMan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...