2011-07-16 11 views
0

私は1から10までの数字を入力するテキストボックスを持っています。テキストボックスに入力された数字に基づいて、多くのテキストボックスを動的に生成する必要があります。誰もこれを行うに私を助けることができますか?動的テキストボックスの生成

答えて

4
<input id="input" /> 
<div id="space"></div> 
<script> 
$("#input").keyup(function(){ 
    var $count = $(this).val(); 
    $("#space").html(''); 
    for ($i=0;$i<$count;$i++) 
    { 

    $("#space").append('<input name="'+$count+'_input" />'); 
    } 

}); 
</script> 

デモ:http://sandbox.phpcode.eu/g/d6046.php

+0

とjQueryタグはありますか? – epascarello

+0

どのjqueryタグですか? – genesis

+0

私はそれが@ epascarelloのポイントだと思います。 – Bojangles

0

element.onchange

document.getElementById("YourId").onchange = function(){ 
    alert("The text in the textbox has changed"); 
} 
+0

これは、ユーザーがボタンを押したと思うテキストボックスを残すことを要求します。 –

関連する問題