JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 18th, 2012, 11:50 AM
jimakos17 jimakos17 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 jimakos17 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 33 sec
Reputation Power: 0
Need Help Debugging Script/Error in Script - On keypress do sth

Please explain me how to do the following.
When a user press a key to understand which key has pressed
and execute a command.
I've already tried these:

function BIU(event) {
var isCtrl = false;
if(event.which == 17) isCtrl=true;
if(isCtrl == true) {
var cRange = document.selection.createRange();
cRange.execCommand('Italic');
}
}
and I inserted in my <div>
onkeypress="BIU(this)"

I'm trying in that way to allow the user executing commands
similars to that of an editor.
Thank you very much in advance.

Reply With Quote
  #2  
Old September 19th, 2012, 04:09 AM
Don475 Don475 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 7 Don475 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 54 sec
Reputation Power: 0
Someone has to know what is going on! please help

Reply With Quote
  #3  
Old September 19th, 2012, 10:37 AM
jimakos17 jimakos17 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 jimakos17 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 33 sec
Reputation Power: 0
function Selected(e) {
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);

if(character=='+'){
var t1= new Array();

t1[0]=document.createElement('input');
t1[0].type='checkbox';
t1[0].name='checkbox1';
t1[0].value = "value";
document.getElementById('myDiv').appendChild(t1[0]);

}

In that way when I press +
a check box appears but in the next line as
+
checkbox

I want the checkbox in the same line without the +

Any idea how I can delete the + and show the checkbox where the caret is?
Thank you again in advance.

PS. unfortunately some execCommand are supported only by IE, that's why I didn't use
document.execCommand ('insertInputRadio', false, null);

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Need Help Debugging Script/Error in Script - On keypress do sth


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap