Jump to content

Javascript paste? I need help please


da_cracken

Recommended Posts

Hi,
   I need help please. I'm working on a script to paste items into a text area. The scipt pastes, but it pastes where it wants to paste, and not where i want it to go. I want it to paste at the text selector, but it only pastes at the very end of any text already in the box. I have pasted a small part of the script below and I pray someone can figure out the error of my ways for me ;D

function BR()
{
document.Pro.write.value += ("<BR>\n")
}
Link to comment
Share on other sites

Because that is what you are telling it do. The += adds whats on the right to the end of whats on the left. So its always going to add [nobbc]<br>[/nobbc] on to the end of whats in you textarea

If you want to get javascript to add [nobbc]<br>[/nobbc] where your curser is, then it'll be a bit more advanced as you'll have to use javascript find out where the curser is located to and then get it to add br tag in that location.

Also whay are you adding br tag into a textarea anyway? If its to preserver line breaks. Dont bother just use the nl2br PHP function to preserve the line breaks.

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.