How do I get the cursor to focuss at certain point in a text area?
How do I get the cursor to focuss between the html tags that this
script writes into a text area so that user will be able to type
his text without moving the cursor into place?
<script language=javascript>
function addTextFormat(format)
{
textarea1.value=textarea1.value+format;
var string=textarea1.value
}
</script>
I want to add a:
Write new paragraph here")'>
Write new quotation paragraph here")'>
Andy Kohlenberg
Jerusalem, Israel
akohl posted this at 10:05 — 28th June 2001.
They have: 117 posts
Joined: Feb 2001
Does that mean it can't be done?
detox posted this at 13:35 — 28th June 2001.
They have: 571 posts
Joined: Feb 2001
Why don't you simply write the html to the screen after you have the users input? As far as I know you can't focus to a specified area within an input area. But I'll check it out for you..
akohl posted this at 19:40 — 28th June 2001.
They have: 117 posts
Joined: Feb 2001
Thanks for checking it out.
Basically, I just want to make it easy for the user to write html code for new articles which are to be written to a database field or a text file and then included in a new page displayed on his site. Just click paragraph and start typing one. Just click quotation and start typing. If he has to place the cursor correctly, I may as well have him write the tags as well. So thats basically the idea.
Andy Kohlenberg
Jerusalem, Israel
detox posted this at 01:46 — 29th June 2001.
They have: 571 posts
Joined: Feb 2001
My thinking is you can easily set this up to write after the input is taken. Have radio buttons or some input to get which tag they want, then set the input text as a variable. Then write a little sub or function that takes the tag selection, and writes the tags around the text.
I could put together a little demo in no time if you want.
that is for asp, but you could easily do this even just with Javascript. I don't know about PHP. You might want to ask in server side scripting.
let me know...
PLUS: if you want to give them tag choices mid stream,ie bold some text midway through a paragraph. Simply have a button that upon selection inserts a text placeholer around the selected text, and than have a replace function which then writes the alternate tags to the text upon submission.
akohl posted this at 11:32 — 1st July 2001.
They have: 117 posts
Joined: Feb 2001
Let me see if I have this right.
I give the client a text area and a set of radio buttons; first heading, second heading, paragraph, quote. He pastes a lengthy text string into the text box, selects his heading, then clicks the heading button. I use the onfucus event on the radio button to trigger a function that adds the appropriate tages to the selected text and then returns the appended string to its place inside the text area. When he finishes formating the entire article, he clicks the submit button which sends the value of the entire stirng of the text area to the server with all the html tags.
Just two questions;
1)
What would the property be of the selected segment of text? textarea1.selectedText.value or what?
2)
What did you mean by a text placeholder? Some never used characters that will be replaced by html tags? Is there an advantage to this over inserting the html tags directly?
Please don't write the function for me. That would take away most of the fun. But I woundn't mind some help on finding the property(ies) I need and any other comments you might have.
Thanks
Andy Kohlenberg
Jerusalem, Israel
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.