• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating form fields on button click

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

In my project there a place in the UI where i should provide a button called add and when the user clicks on add i need a create a FILE control.When the user submits the form i need to capture the file name and store the file in the database.How can i handle this using java script.Please give me solution.

Thanks in Advance....
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

You should have somePlaceHolder for adding element into the html through javascript so that when you do the page doesnot get refresh like div or span

<div id="div1"></div>

add the onClick event on your so called add button which will then call some javascript method


In this javaScript method now you can add

function showSomeThing(){
var divName =document.getElementById("div1");
divName.innerHTML="<input type='file' name='FileName'/>";
}

and on your server side code you can access this fileName using someName as parameter name, sent from the client.
[ June 13, 2007: Message edited by: prateek chaudhari ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Others solutions is to have a set amount of controls there and use the css display to show the hidden elements one at a time.

Another is to use document.createElement() and appendChild()

Eric
[ June 13, 2007: Message edited by: Eric Pascarello ]
 
Naveen Koneti
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi prateek

Thanks for the reply I tried with your code I am not getting the multiple buttons,I mean it is creating button only once and can clearly explain how to access the created text in my serverside code ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic