Jump to content

Insert at cursor position - alteration to existing script


Canman2005

Recommended Posts

Hi all

 

I have a simple form which has two buttons and a form field, when you click one of the two buttons, it inserts the value of the selected button into the form field.

 

The code is

 

<form>
<input type="text" name="tester">
<input type="button" value="1" onclick="tester.value+='1'">
<input type="button" value="2" onclick="tester.value+='2'">
</form>

 

At the moment, when you click one of the two buttons, it always inserts the value at the end of whatever has already been entered in the text field.

 

I want to change this, so that it inserts the button value into the text field, but at the position of where the text cursor is blinking.

 

Can this be done??

 

Hope that makes sense

 

Any help would be gratefully appreciated.

 

Thanks in advance

 

Thak

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.