Inserting text into multine inputs
Moderator: General Moderators
Inserting text into multine inputs
Hi I need to create JavaScript to control text in a multi-line input, basicall, when a user clicks a button, it should enter some text into the multi-line input, weherever the cursor currently is
how do I acheive this .. hopefully without writing two versions one for IE and NN
M
http://www.alljammin.com[/b]
how do I acheive this .. hopefully without writing two versions one for IE and NN
M
http://www.alljammin.com[/b]
-
phpfreak
- Forum Commoner
- Posts: 30
- Joined: Fri Mar 21, 2003 10:28 am
- Location: New Jersey,USA
- Contact:
hi there
Hi I need to create JavaScript to control text in a multi-line input, basicall, when a user clicks a button, it should enter some text into the multi-line input, weherever the cursor currently is
how do I acheive this .. hopefully without writing two versions one for IE and NN
M,
I really didnt understand your question i hope the following with be of use to u:
if you are planning to write some text to any particular form element like for example you have a form called "form1" and you have a text box named "mytextbox" then you can do the following:This is a function goes to the particular textbox and writes the comment there whenever the user clickt the button Hi
-------------------------------------------------------------------------------------
<script language="JavaScript">
function testme()
{
document.form1.mytextbox.value="hi MR/Miss. M , How are u today";
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="mytextbox" id="mytextbox" size="70">
</form>
<button onClick="testme();" id="button">Hi</button>
-------------------------------------------------------------------------------------
I hope this helped , if this isnt what you want then email me i will try to help u.
bye
srinivas
how do I acheive this .. hopefully without writing two versions one for IE and NN
M,
I really didnt understand your question i hope the following with be of use to u:
if you are planning to write some text to any particular form element like for example you have a form called "form1" and you have a text box named "mytextbox" then you can do the following:This is a function goes to the particular textbox and writes the comment there whenever the user clickt the button Hi
-------------------------------------------------------------------------------------
<script language="JavaScript">
function testme()
{
document.form1.mytextbox.value="hi MR/Miss. M , How are u today";
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="mytextbox" id="mytextbox" size="70">
</form>
<button onClick="testme();" id="button">Hi</button>
-------------------------------------------------------------------------------------
I hope this helped , if this isnt what you want then email me i will try to help u.
bye
srinivas
the emoticon()-function of this board does it for IE. With a slight change mozilla is able to do so, too.
Code: Select all
<html>
<head>
<script type="text/javascript">
function emoticon(text)
{
text = ' ' + text + ' ';
if (document.post.message.createTextRange && document.post.message.caretPos)
{
var caretPos = document.post.message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
document.post.message.focus();
}
else if(document.post.message.selectionStart)
{
s1 = document.post.message.value.substring(0, document.post.message.selectionStart);
s2 = document.post.message.value.substring(document.post.message.selectionStart, document.post.message.value.length);
document.post.message.value = s1 + text + s2;
}
else
{
document.post.message.value += text;
document.post.message.focus();
}
}
</script>
</head>
<body>
<form name="post">
<textarea name="message"></textarea>
<input type="button" onClick="javascript:emoticon('test');" value="test"/>
</form>
</body>
</html>I've tried the code above, iut works fine, but it only ever adds text to the end of the textarea, even if the text caret is not at the end of the text area input, or even if text is selected
any ideas?
http://www.alljammin.com
any ideas?
http://www.alljammin.com
part for IE. It only applies to the emoticons on the left side for this board.// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/vie ... 52/fid/130
function storeCaret(textEl) {
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
my vmware evaluation key expired and once again I killed my notebook. It's always the same. "Hey, looks great, let's test it. Wow, and if I change this? gnaa.....". This time I tried to replace the "idle process". Not such a good idea
only sporadic IE testing for some days
Ok, I could use the IE6 installed on this box ...but somehow I don't want to
only sporadic IE testing for some days
Ok, I could use the IE6 installed on this box ...but somehow I don't want to
