•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,288 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,334 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1593 | Replies: 15 | Solved
![]() |
| |
•
•
Join Date: Apr 2005
Location: New York state
Posts: 464
Reputation:
Rep Power: 5
Solved Threads: 72
Absolutely
So if you have a form such as
You would have something along this lines
javascript Syntax (Toggle Plain Text)
function addInput(parentID) { newInput = document.createElement('input'); newInput.type = 'file'; newInput.name = '<put name you want here>'; document.getElementByID(parentID).appendChild(newInput); }
html Syntax (Toggle Plain Text)
<form action="something.php" method="POST" enctype="multipart/form-data" id='imagesForm'>
html Syntax (Toggle Plain Text)
<input type="button" onclick="addInput('imagesForm')" value="Upload Another" />
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Apr 2005
Location: New York state
Posts: 464
Reputation:
Rep Power: 5
Solved Threads: 72
•
•
Join Date: Feb 2008
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
thanks its working now.
the result that I want should be like this
I m reading some tutorials now, to get the code above i ve treid so far this
I can't get the code run, but I m working on this, any help well be approciated
.
the result that I want should be like this
<tr>
<td width="150">foto 1:</td>
<td width="250"><input type="file" name="foto1" size="30" /></td>
</tr>
<tr>
<td width="150">Description:</td>
<td width="250"><input type="text" name="description1" size="30" /></td>
</tr> function addInput(parentID)
{
newInput = document.createElement('input');
newInput.type = 'file';
ewInput.name = 'foto';
var r = document.createElement('tr');
var ca = document.createElement('td');
var cb = document.createElement('td');
var t = document.getElementById(parentID);
ca.appendChild(newInput);
cb.appendChild(newInput);
r.appendChild(ca);
r.appendChild(cb);
t.appendChild(r);
}
. •
•
Join Date: Apr 2005
Location: New York state
Posts: 464
Reputation:
Rep Power: 5
Solved Threads: 72
You might want to use a bit more descriptive names. Also, it's not working because you aren't first appending ca (the td) to anything. You must first append the new row (r) to t(parent) then append ca to r, and so on.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Feb 2008
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
it's not working because you aren't first appending ca (the td) to anything. You must first append the new row (r) to t(parent) then append ca to r, and so on.
t.appendChild(r);
r.appendChild(ca);
r.appendChild(cb);
ca.appendChild(newInput);
cb.appendChild(newInput);•
•
Join Date: Apr 2005
Location: New York state
Posts: 464
Reputation:
Rep Power: 5
Solved Threads: 72
I'm not entirely sure what the extra TD is for but this is what it should look like
javascript Syntax (Toggle Plain Text)
function addInput(parentID) { newInput = document.createElement('input'); newInput.type = 'file'; newInput.name = 'photo'; var parent = document.getElementById(parentID); var row = document.createElement('tr'); var td1 = document.createElement('td'); parent.appendChild(row); row.appendChild(td1); td1.appendChild(newInput); }
Last edited by ShawnCplus : Feb 12th, 2008 at 10:34 pm.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Feb 2008
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
this Code work great on FF but not in IE
function addInput(parentID)
{
newInput = document.createElement('input');
newInput.type = 'file';
newInput.name = 'foto';
var parent = document.getElementById(parentID);
var row1 = document.createElement('tr');
var td1 = document.createElement('td');
td1.setAttribute("width","150");
var txt = document.createTextNode("foto2");
;
var td2 = document.createElement('td');
td2.setAttribute("width","250");
parent.appendChild(row1);
row1.appendChild(td1);
row1.appendChild(td2);
td1.appendChild(txt)
td2.appendChild(newInput);
}![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Navigation Menu Issue (ASP.NET)
- Pixelated Images... (Windows NT / 2000 / XP / 2003)
- Reducing pixelization in images (ASP.NET)
- php photo gallery extra code needed (PHP)
- windows explorer not opening (Web Browsers)
- IE6 has been constantly hijacked by .... (Viruses, Spyware and other Nasties)
- My laptop is v slow to startup (Windows NT / 2000 / XP / 2003)
- System Processes in XP? NetTsk.exe? (Windows NT / 2000 / XP / 2003)
- IEDLL.EXE and Loader.exe error (Windows NT / 2000 / XP / 2003)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Any Help Appreciated
- Next Thread: Printing content of a div/table element


Hybrid Mode