?
Solved

Activate 'overwrite'-mode with JScript

Posted on 2000-04-10
7
Medium Priority
?
755 Views
Last Modified: 2012-05-04
Does anybody know a way to activate/deactivate the overwritemode (insert-key toggle) within a textbox, with JScript in IE.

0
Comment
Question by:mnprsd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:Deathead
ID: 2701182
Unfortunatly this is impossible in JavaScript, The creators feel it would be a security risk. Sorry
0
 

Author Comment

by:mnprsd
ID: 2707421
Sad! Here is my problem. I have a textbox with initially five hyphens in it ("-----"). Each of these hyphens represents a flag. The value can be any number from 0 to 9, or -. For example "--1-2".

The users will often change these values and therefore I wanted to initially set the the textbox in overwrite-mode.

If anyone have any great workaround for this problem I'd be happy to know.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2707970
How about 5 dropdowns???
<select name=s1>
<option value="-">-
<option value=0>0
<option value=1>1
<option value=2>2
<option value=3>3
<option value=4>4
<option value=5>5
<option value=6>6
<option value=7>7
<option value=8>8
<option value=9>9
</select><select name=s2>
<option value="-">-
<option value=0>0
<option value=1>1
<option value=2>2
<option value=3>3
<option value=4>4
<option value=5>5
<option value=6>6
<option value=7>7
<option value=8>8
<option value=9>9
</select><select name=s3>
<option value="-">-
<option value=0>0
<option value=1>1
<option value=2>2
<option value=3>3
<option value=4>4
<option value=5>5
<option value=6>6
<option value=7>7
<option value=8>8
<option value=9>9
</select><select name=s4>
<option value="-">-
<option value=0>0
<option value=1>1
<option value=2>2
<option value=3>3
<option value=4>4
<option value=5>5
<option value=6>6
<option value=7>7
<option value=8>8
<option value=9>9
</select><select name=s5>
<option value="-">-
<option value=0>0
<option value=1>1
<option value=2>2
<option value=3>3
<option value=4>4
<option value=5>5
<option value=6>6
<option value=7>7
<option value=8>8
<option value=9>9
</select>

Michel
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:mnprsd
ID: 2710798
Unfortunately, this textbox isn't the only one. There are four of these textboxes per row, and there can be multiple rows, sometimes over a hundred. Sorry, but I forgot to mention that.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 2710904
Does make a difference!

Michel
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 600 total points
ID: 2737299
You can intercept a keydown and change it to an INSERT key, but that just toggles the state.  The following code uses TEXTAREA to simulate inputs.  You need five of them, but as shown, they take very little more space than a 5-clm text input.

To make the TEXTAREA simulation work, it selects the entire field on focus, then discards any non-visible characters on blur.

I also added a flourish: It validates each incoming character.

Your submit function would need to collect all the inputs but that should be simple since they are guaranteed to be valid and each id exactly one-character long.

<html>
<SCRIPT>
//----------- written by Dan Rollins
//----------- some real-time data validation
function DoKeyPress() {
    var nCode= window.event.keyCode;
    if ((nCode==45) || ((nCode>=48) && (nCode<=57)) ) {
        //no problem
    }
    else {
          alert("Please enter value between 0 and 9 or -" );
            window.event.keyCode= 0; // cancel the character
    }
}
//---------- make TextArea more like < INPUT TYPE=text>
function DoOnFocus( oInput ) {
        oInput.select();
}
//---------- parm check, removes all but the final character (the one that is visible)
function DoOnBlur(oInput) {
      var s= "-"+oInput.value;
      oInput.value= s.substr(s.length-1,1);
}
</SCRIPT>

Item 1:
<TEXTAREA STYLE="overflow:hidden" ID=Fld00_0 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >1</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld00_1 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >2</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld00_2 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >3</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld00_3 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >4</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld00_4 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >5</TEXTAREA>
&nbsp;&nbsp;Item 2:
<TEXTAREA STYLE="overflow:hidden" ID=Fld01_0 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >1</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld01_1 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >2</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld01_2 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >3</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld01_3 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >4</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld01_4 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >5</TEXTAREA>
&nbsp;&nbsp;Item 3:
<TEXTAREA STYLE="overflow:hidden" ID=Fld02_0 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >1</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld02_1 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >2</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld02_2 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >3</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld02_3 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >4</TEXTAREA>
<TEXTAREA STYLE="overflow:hidden" ID=Fld02_4 ROWS=1 COLS=1 onfocus="DoOnFocus(this)"  onblur="DoOnBlur(this) "onkeypress="DoKeyPress()" >5</TEXTAREA>

<html>


0
 

Author Comment

by:mnprsd
ID: 2746475
This solution actually works!! Maybe not as pretty as I had hoped it could be, but still working and the user shouldn't notice any lack in functionality! I will also add a feature that sets focus to the next <textarea> whenever a valid key is pressed. Thanks man!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question