0

I am trying to insert text in to an input field using this code.

This is the code I am using:

<input class="cid" type="text" name="c1" />
<input class="cid" type="text" name="c2" />
<input type="button" value="Insert Text" onclick="insertAtCaret('c1','TEXTTOINSERT1');insertAtCaret('c2','TEXTTOINSERT2');" />

But nothing is happening. I don't know JS so I'm not sure if the JS code I referenced before is only for textareas which did work when I tested.

Thanks!

0

1 Answer 1

3

The code in the link uses the ID of the element, so you'll have to add an ID :

<input class="cid" type="text" name="c1" id="c1" />
<input type="button" value="Insert Text" onclick="insertAtCaret('c1','TEXTTOINSERT');" />

FIDDLE

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.