473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Insert At Cursor

nathj
938 Expert 512MB
Good morning,

Well after the long Christmas break I'm finally back on-line, although my first post is to ask for help.

I am working on a simple admin panel for a site I have - it will enable other people to keep the main areas of the site up to date if I am not available. Part of this admin process needs an insert at cursor function so people can insert images at the right place.

The code I have (see below) works fine for FF but for IE nothing happens.

Expand|Select|Wrap|Line Numbers
  1. function insertAtCursor(myField, myValue) 
  2. {
  3.  
  4.     var loTextArea = document.getElementById(myField) ;
  5.  
  6.     if (document.selection) 
  7.     {
  8.         //IE support
  9.         myField.focus();
  10.         sel        = document.selection.createRange(); 
  11.         myValue    = myValue + sel.text;    
  12.     }
  13.     else if (loTextArea.selectionStart || loTextArea.selectionStart == '0')     
  14.     {                                                                            
  15.         //MOZILLA/NETSCAPE support     
  16.         var startPos        = loTextArea.selectionStart;
  17.         var endPos            = loTextArea.selectionEnd;
  18.         loTextArea.value    = loTextArea.value.substring(0, startPos) + myValue + loTextArea.value.substring(endPos, loTextArea.value.length);
  19.     }
  20.     else
  21.     {
  22.         loTextArea.value += loTextArea;
  23.     }
  24.  
  25. }
  26.  
I say nothing happens because that is exactly what happens - nothing. I am calling the function with the ID of a textarea and the string '[img]' which is translated later.

So in FF the insert happens where the cursor is but in IE nothing happens at all.

Any ideas on what is going wrong here?

Many thanks
nathj
Jan 19 '09 #1
3 1669
acoder
16,027 Expert Mod 8TB
See if this thread helps.
Jan 19 '09 #2
nathj
938 Expert 512MB
That link turns up a 404, any ideas where the content is now?

Cheers
nathj
Jan 20 '09 #3
acoder
16,027 Expert Mod 8TB
Sorry, the link was incorrect. I've fixed it now.
Jan 20 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: grumfish | last post by:
I'm trying to add a row to a MySQL table using insert. Here is the code: connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", db="japanese") cursor = connection.cursor()...
2
by: yurps | last post by:
Hi I have a weird problem I want to cursor thru the values in a temporary table and use the values to do a select statement to insert into another temporary table...This select statement uses a...
3
by: David Mitchell | last post by:
Hello, I am a complete beginner with Python. I've managed to get mod_python up and running with Apache2 and I'm trying to a simple insert into a table in a MySQL database. I'm using the...
3
by: Developer | last post by:
I use the RichTextBox and sometimes put it into overwrite mode. I'd like the cursor to show whether its in overwrite or insert mode. I often use Cursor.Current = Cursors.WaitCursor and...
7
by: David Bear | last post by:
I have a dictionary that contains a row of data intended for a data base. The dictionary keys are the field names. The values are the values to be inserted. I am looking for a good pythonic...
1
by: peteh | last post by:
Hi All; I have a 2.5mm row table (very wide columns) on an UDB v8.2.3 (DPF - 6x10) AIX box. We were doing some performance testing to determine the pros and cons of delete/insert vs load from...
4
by: mathon | last post by:
Hello, im currently implementing a binary search tree means, that a greater number than root will be added as right child and a less number as left child. My insert function looks currently like...
14
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
6
by: eighthman11 | last post by:
Hi everyone: Using Sql Server SQL 8 I'm trying to INSERT records into a "can software package" batch table. I have a work-table that mimics the batch table. After manipulating the records in...
6
by: Abandoned | last post by:
Hi.. I use the threading module for the fast operation. But i have some problems.. This is my code sample: ================= conn =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.