动态表格 [英] Dynamic Form

查看:62
本文介绍了动态表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,当点击时使用下面的功能将一个输入框添加到页面。如何让它在输入框之前显示标签:


名称:输入框到这里


function add_student(){


var StudentFirstname = document.createElement(''input'');

StudentFirstname.type =''text'';

StudentFirstname.size ='''45'';

StudentFirstname.name =''Student2_Firstname'';


document.forms.Registration.appendChild(StudentFir stname);


}

I have a button that when clicked uses the below funciton to add an input box to the page. How can I get it to show a label before the input box:

Name: input box goes here

function add_student(){

var StudentFirstname=document.createElement(''input'');
StudentFirstname.type=''text'';
StudentFirstname.size=''45'';
StudentFirstname.name=''Student2_Firstname'';

document.forms.Registration.appendChild(StudentFir stname);

}

推荐答案

嗨...


i guess你总是知道怎么做;)...


1.创建一个span-Element

2.使用createTextNode创建一个textNode(''your_label '')

3. appendChild textnode到span

4.创建你的输入节点

5. appendChild输入节点到跨度

6. appendChild你的表格范围


亲切的问候
hi ...

i guess you always know how to do that ;) ...

1. create a span-Element
2. create a textNode with createTextNode(''your_label'')
3. appendChild the textnode to the span
4. create your input-Node
5. appendChild the input-node to the span
6. appendChild the span to your form

kind regards


非常感谢你! : - )
thank you very much! :-)


随时欢迎您...;)当您有更多问题时回来


亲切的问候
your are always welcome ... ;) come back when you have more questions

kind regards


这篇关于动态表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆