Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1611 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Javascript: Add field on link click?

Thread title: Javascript: Add field on link click?
Closed Thread    
    Thread tools Search this thread Display Modes  
12-15-2006, 10:49 PM
#1
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old  Javascript: Add field on link click?

Is it possible to add an additional drop down menu (select field) on the click of a button/link?

12-15-2006, 11:09 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Yes. Look into using document.createElement

12-15-2006, 11:25 PM
#3
MaxS is offline MaxS
Status: Senior Member
Join date: Aug 2005
Location: New York
Expertise:
Software:
 
Posts: 825
iTrader: 1 / 100%
 

MaxS is on a distinguished road

  Old

Here's a snippet from one of my sites.

Code:
var fUploads = 0;
function addField()
{
document.getElementById('fields').innerHTML = document.getElementById('fields').innerHTML + "<input type=\"file\" name=\"uploads[" + fUploads + "]\" /><br />";
fUploads++;
}
Code:
<a href="javascript:addField();">Add Field</a>
You should be able to figure it out from there. If not, just post back.

12-16-2006, 01:27 AM
#4
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

Amazing MaxS.. works perfect. Thanks a bundle.

Regards,
Jeff

12-16-2006, 11:35 PM
#5
Cooleo is offline Cooleo
Status: Member
Join date: Sep 2005
Location: Stoke, UK
Expertise:
Software:
 
Posts: 151
iTrader: 0 / 0%
 

Cooleo is on a distinguished road

Send a message via MSN to Cooleo

  Old

In future, use the =+ operator to add something to itself!
i.e.
PHP Code:
document.getElementById('fields').innerHTML =+ "<input type=\"file\" name=\"uploads[" fUploads "]\" /><br />"

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed