Aug 27

Wondering how to check the content of an FCKEditor? You will love this simple code!!!

<?php
include("fckeditor/fckeditor.php") ;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title>FCKeditor - Sample</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="robots" content="noindex, nofollow">
		<script>

function getRTEText(fckinst){
  var oEditorHTML = FCKeditorAPI.GetInstance(fckinst).GetHTML();
  alert(oEditorHTML);
}
</script>
	</head>
	<body>

		<form action="request.php" method="post">

<?php
	$oFCKeditor = new FCKeditor('content');
	$oFCKeditor->BasePath = "fckeditor/";
	$oFCKeditor->Value = $content['message'];
	oFCKeditor->Config['UserFilesPath'];
	$oFCKeditor->Height = "440";
	$oFCKeditor->Create();
?>

			<br>
			<input type="button" onclick="javaScript:getRTEText('content');" value="check">
			<input type="submit" value="Submit">
		</form>
	</body>
</html>
Tagged with:
Aug 06

These functions are specially designed for dynamic pages, and work without error with zero, one, or more radio buttons. Also, because the radio length is saved before looping, this function is much faster. Finally, the functions are granted to the public domain.

Source Code

return the value of the radio button that is checked
return an empty string if none are checked, or there are no radio buttons

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

set the radio button with the given value as being checked
do nothing if there are no radio buttons
if the given value does not exist, all the radio buttons are reset to unchecked

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
Tagged with:
preload preload preload
Bless CV