Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Activate 'overwrite'-mode with JScript

Posted on 2000-04-10
7
Medium Priority
?
758 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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.
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…

610 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