I would like to ask if anyonce can help me.
I have form with a drop down list. my problem is that I am using TinyMCE as editor.
When I select an item in the drop down it doesn’t populate the TinyMCE textarea but another textarea is open by jQuery.
Here’s my code, can anyone help me to fix so that the results of the drop down will show on the TinyMCE editor.
Thanks a lot.
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script><br />
<script type="text/javascript">
$(document).ready(function () {
$('#select').change(function () {
var option = $(this).val();
$.get('select.php', {select: option}, function (data) {
$('#result').html(data).hide().fadeIn(1);
});
});
});
</script>
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({mode: "textareas", editor_selector: "mceEditor"});
$(document).ready(function () {
$('form').submit(function ()
{
alert(tinyMCE.get('result').getContent());
});
});
</script>
</head>
<select name="select" id="select">
<option value="">Select</option>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
</select>
<form id="ajax-form" class="autosubmit" method="POST" action="">
<textarea class="mceEditor" id="result" name="notes"/></textarea>
<input type="submit">
</form>
Here’s my PHP that get the data:
<?php
if($_GET['select'] == 'option1') {
echo 'the option you have chosen is 1';
} elseif($_GET['select'] == 'option2') {
echo 'the option you have chosen is 2';
} elseif($_GET['select'] == 'option3') {
echo 'the option you have chosen is 3';
} elseif($_GET['select'] == 'option4') {
echo 'the option you have chosen is 4';
} elseif($_GET['select'] == 'option5') {
echo 'the option you have chosen is 5';
}
?>
Instead of
$('#result').html(data).hide().fadeIn(1);(why do you call hide here?)use