Jump to content

Recommended Posts

This is my AJAX handler function. Basically I'm passing this function 2 values as a string concatenated by "||". One value needs to go in a text box... the other needs to show up as the value of a textarea. The problem is, the "title" box is getting the value "undefined"... and that's obviously not how you fill a textarea's value.

 

Help?!

 

EDIT: Sorry, forgot the code:

 

function handleEditor()
{
if(http.readyState == 4)//Finished loading the response
{
	var vals = http.responseText;
	var vals2 = new Array();
	vals2 = vals.split('||', vals);
	document.getElementById('title').value = vals2[0];
	document.getElementById('news_text').value = vals2[1];
	document.getElementById('editor').style.display = "block";
} 		
}

Link to comment
https://forums.phpfreaks.com/topic/51729-solved-textarea-value-equivalent/
Share on other sites

Using ie?

 

i know that innerHTML doesnt work with ie, so you'll have to use value. I dont see why that wouldnt work in other browsers though.

 

 

you can try a few methods, or all of them

 

ele.innerHTML = vals2[1];

ele.data = vals2[1];

ele.appendChild(vals2[1]);

i know that innerHTML doesnt work with ie, so you'll have to use value. I dont see why that wouldnt work in other browsers though.

 

Why's that? I use innerHTML in IE6 and 7 in multiple scripts just fine. IE only limits certain types of elements that you cannot user innerHTML on (like tables). You can use it on textareas without a problem, and this is, IMHO, the best way to adjust the "value" of a textarea field.

It's the fact that I'm using TinyMCE as an editor... if I use a regular textarea... it works fine.  Now what?

 

Sorry, I missed that before... TinyMCE has some really funky attribute settings in their textarea. Here is a link to look at for some additional ideas:

 

http://blorum.org/forum.php?p=356

 

From reading some in the TinyMCE forums, it seems that you actually have to modify the content of the textarea through the tinymce object rather than your normal methods.

 

Here's a very interesting function I saw on this page on moxiecode's site:

function ajaxLoad() {
var inst = tinyMCE.getInstanceById('content');

// Do you ajax call here
inst.setHTML('HTML content that got passed from server.');
}

 

That should at least be modifiable to work with what you're after, I would think.

oh tinymce, ive used it and had the same issues. if you havent figured it out by time i get to work, i will look through some of my code

 

what i did was make it so that if you click on the textarea, it turned into a tinymce editor, maybe that would help you out

alright it is kinda long. i actaully had to modify some of the tinymce code to get it to do ajax calls, it is in their wiki, i dont know if you need that part, but ill see if i can find it

 

 

i am using mootools, so the syntax may be kinda off, but this is my code to show the text editor. on load of the page, i replace every textarea with a div and set the html of that div to the textarea's content and then hide the textarea by doing diplay: none.

 

then onclick of that div i run this function. the tinymce command says make that textarea an mceEditor. you'll need to know the textarea's id

 

tinyMCE.execCommand('mceAddControl', false, obj.id);

 

		div.addEvent('click', function(event){
			div.setStyles({
				'display': 'none'
			});

			obj.setStyles({
				'display': 'block'
			});

			if(obj.getTag() == 'textarea') 
				tinyMCE.execCommand('mceAddControl', false, obj.id);
			else
				obj.focus();

		});

 

also in the declaration of the mceEditor in the head tag you have to tell it to only load certain textareas with mode: "exact"

 

here is mine as an example

 

tinyMCE.init({
	mode:									"exact",
	theme:									"advanced",
	plugins:								"fullscreen",
	theme_advanced_toolbar_align: 			"left",
	theme_advanced_path_location:			"bottom",
	theme_advanced_toolbar_location: 		"top",
	theme_advanced_buttons1:				"bold,italic,forecolor,,separator,justifyleft,justifyright,separator,bullist,separator,removeformat,image, fullscreen,separator,code",
	theme_advanced_buttons2: 				"",
	theme_advanced_buttons3: 				"",
	file_browser_callback:					'myImageBrowser'
});

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.