Jump to content

Need Help..


phpSensei

Recommended Posts

I asked for help and someone posted this to me...

 

function replaceText(text, textarea)
{
// Attempt to create a text range (IE).
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
{
	var caretPos = textarea.caretPos;

	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	caretPos.select();
}
// Mozilla text range replace.
else if (typeof(textarea.selectionStart) != "undefined")
{
	var begin = textarea.value.substr(0, textarea.selectionStart);
	var end = textarea.value.substr(textarea.selectionEnd);
	var scrollPos = textarea.scrollTop;

	textarea.value = begin + text + end;

	if (textarea.setSelectionRange)
	{
		textarea.focus();
		textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
	}
	textarea.scrollTop = scrollPos;
}
// Just put it on the end.
else
{
	textarea.value += text;
	textarea.focus(textarea.value.length - 1);
}
}

 

it is a function to wrap a bbcode around A TEXT, to a text area..

 

How would you make the form, and text area? What should I call them?

Link to comment
Share on other sites

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.