[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 762
  • Last Modified:

Activate 'overwrite'-mode with JScript

Does anybody know a way to activate/deactivate the overwritemode (insert-key toggle) within a textbox, with JScript in IE.

0
mnprsd
Asked:
mnprsd
1 Solution
 
DeatheadCommented:
Unfortunatly this is impossible in JavaScript, The creators feel it would be a security risk. Sorry
0
 
mnprsdAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mnprsdAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
Does make a difference!

Michel
0
 
DanRollinsCommented:
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
 
mnprsdAuthor Commented:
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now