Problems dynamically adding to form (trying to use onChange and appendTo)

so I want my form to extend in different ways depending on the selection of a drop down box. I have got my javascript working so that onchanging my selection it will carry out something. But I am trying to use the appendTo() method as I have used before; for adding a single input, to work for implementing a div and a few inputs. Its not working, hence the post ;) so I was hoping you guys could enlighten me as to a better method? here is my current code (courtesy of Mark): var selectmenu = document.getElementById("type"); selectmenu.onchange = function() { var chosenoption = parseInt(this.options[this.selectedIndex].value); switch (chosenoption) { case 1: $('').appendTo('#temp'); break; case 2: $('').appendTo('#temp'); break; case 3: $('').appendTo('#temp'); break; } }; note: updated since answers. here is constructed in [jsfiddle][1] it does nothing currently. Please help? :D [1]: http://jsfiddle.net/Qzhyp/
can we see the html too please ?

以上就是Problems dynamically adding to form (trying to use onChange and appendTo)的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏