2011-09-09 7 views
0

JavaScriptを使用して仮想キーボードを作成しようとしています。キーをクリックしようとするとdivが作成されますが、テキストはキーボードからは出ません。Javascript Virtualkeyboard

alert(targ.childNodes[0].textContent);アラートの文字を表示することはできますが、divに挿入する方法は?

+1

...これを試してみて、私たちは結果をお知らせ –

+0

divにテキストを追加しますか?もしそうなら:document.getElementById( 'textContent')。innerHTML + = valueToAppend。あなたがjqueryを使うことにしたら、http://mottie.github.com/Keyboard/ – galchen

+0

私はdocument.createElementを使ってdivを作成しました。そしてdiv.id = "popup"としてIDを割り当てました。私はキーを押すだけで、divで表示する必要があります – Ashish

答えて

0

String inaプロパティを追加する場合、onclick関数は文字列を取得し、その文字列をpasswordプロパティに追加します。

function getCharText(text){ 

    if(capsEnable == 1) 
     text = text.toUpperCase();  
    var textString= ""; 
    var textValue = document.forms[0].password.value; 
    if(textValue != '') 
      textString = textValue; 
    if(document.forms[0].enableKeyboard.checked == true){  
     if(text == "bs" || text == "BS")  
      textString = textString.substring(0, textString.length-1); 
     else if(text == "ca" || text == "CA") 
      textString = ""; 
     else if(text == "sl" || text == "SL") 
      textString = textString + "\\"; 
     else if(text == "dq" || text == "DQ") 
      textString = textString + "\""; 
     else if(text == "sq" || text == "SQ") 
      textString = textString + "\'";  
     else  
      textString = textString + text ; 
    } 
    var pwd = document.forms[0].password.value; 
    var pwdlen = pwd.length; 
    if(pwdlen<15) 
    { 
     document.forms[0].password.value = textString; 
    } 
} 

はどのようにdiv要素を作成しているし、どのようにその内容を設定しようとしている?

+0

document.createElementを使用してdivを作成した後、div.id = "popup"というIDを割り当てました。私はdivを表示する必要があります。 – Ashish

+0

コードを投稿できますか? – Nagarajan

+0

私はあなたにコードを与えることはできませんが、私は何をしたいのかを探求することができます。私はキー押下時の文字をdivに表示したい、今私は1つの警告(targ.childNodes [0] .textContent)を作成します。このiamの助けを借りて、alertboxに入力された文字を見て、私はdivに表示したいですか? – Ashish

関連する問題