gezocht script om dynamisch meer velden toe te voegen
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dynamic Textbox/title>
<script type='text/javascript'>
// --------------------------------------------------------
// Author : Daxa
// Website : http://www.beyondmart.com/
// --------------------------------------------------------
var inival=0; // Initialise starting element number
// Call this function to add textbox
function addTextBox()
{
var newArea = add_New_Element();
var htcontents = "<input type='text' name='textbx[]'/>";
document.getElementById(newArea).innerHTML = htcontents; // You can any other elements in place of 'htcontents'
}
function add_New_Element() {
inival=inival+1; // Increment element number by 1
var ni = document.getElementById('area');
var newdiv = document.createElement('div'); // Create dynamic element
var divIdName = 'my'+inival+'Div';
newdiv.setAttribute('id',divIdName);
ni.appendChild(newdiv);
return divIdName;
}
</script>
</head>
<body>
<!-- Just call function 'addTextBox()' to add textbox -->
<a onclick='addTextBox()' href='#'>Add New Text Box </a>
<br/>
<!-- Textbox will be added in followng DIV -->
<div id='area'></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dynamic Textbox/title>
<script type='text/javascript'>
// --------------------------------------------------------
// Author : Daxa
// Website : http://www.beyondmart.com/
// --------------------------------------------------------
var inival=0; // Initialise starting element number
// Call this function to add textbox
function addTextBox()
{
var newArea = add_New_Element();
var htcontents = "<input type='text' name='textbx[]'/>";
document.getElementById(newArea).innerHTML = htcontents; // You can any other elements in place of 'htcontents'
}
function add_New_Element() {
inival=inival+1; // Increment element number by 1
var ni = document.getElementById('area');
var newdiv = document.createElement('div'); // Create dynamic element
var divIdName = 'my'+inival+'Div';
newdiv.setAttribute('id',divIdName);
ni.appendChild(newdiv);
return divIdName;
}
</script>
</head>
<body>
<!-- Just call function 'addTextBox()' to add textbox -->
<a onclick='addTextBox()' href='#'>Add New Text Box </a>
<br/>
<!-- Textbox will be added in followng DIV -->
<div id='area'></div>
</body>
</html>
Iemand enig idee?
Gewijzigd op 01/01/1970 01:00:00 door Arne
De code is geen php...
arne schreef op 22.12.2008 15:38:
De code is geen php...
Dat wordt ook niet gezegd. Goed lezen graag.