开发者

Dynamic textbox generation

开发者 https://www.devze.com 2023-03-21 04:44 出处:网络
I have a textbox in which user enters a number between 1 to 10. Based on the number entered in the textbox those m开发者_如何学Pythonany textboxes have to be generated dynamically (i mean without pres

I have a textbox in which user enters a number between 1 to 10. Based on the number entered in the textbox those m开发者_如何学Pythonany textboxes have to be generated dynamically (i mean without pressing any button). Can anyone help me out in doing this??


<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>

demo: http://sandbox.phpcode.eu/g/d6046.php


element.onchange

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号