Results 1 to 2 of 2
  1. #1
    nidhi c is offline Member
    Join Date
    Sep 2009
    Rep Power

    Default retain value of input type file in a jsp file while being dynamically generated

    i have a jsp page where i have a input type file and i m allowing the user to browse files. i have one such input on jsp and the rest i m generating dynamically by javascript.

    this is my jsp code:
    <div id="labelContainer" style="display:inline">
    <table align="center">
    <td align="left"><input type="text" id="label0" name="label0" size="15"></td>
    <td align="center"><input type="file" id="filePath0" name="browsetrainset0"></td>
    <td id="addlabel" ><img src="../images/add.png" title="Add Label" onclick="addLabel()"></td>
    <td id="removelabel"><img src="../images/remove.png" title="Remove Label" onclick="removeLabel('labelDiv0')"></td>

    and this is my javacsritp code:
    function addLabel(){
    var text="";
    text+=("<table id='labelDiv"+lCount+"' align='center'>");
    text+=("<td align='left' style='display:none'><input type='checkbox' checked='true' name='labelchkbox'/></td>");
    text+=("<td align='left' id='label'><input type='text' id='label"+lCount+"' name='label"+lCount+"' size='15'></td>");
    text+=("<td align='center'id='filePath' ><input type='file' id='filePath"+lCount+"'name='browsetrainset"+lCoun t+"'></td>");
    text+=("<td id='addlabel' ><img src='../images/add.png' title='Add Label' onclick='addLabel()'></td>");
    text+=("<td id='removelabel'><img src='../images/remove.png' title='Remove Label' onclick=\"removeLabel('labelDiv"+lCount+"')\"></td>");
    document.getElementById("labelContainer").innerHTM L+=text;

    but i m not able to retain the value of the file path i browse, on the jsp page once i click the add label and generate another input type file.
    I am using IE7. Please tell me how to reatin the value of the browsed files so that i can use them further.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    i remember something awful about HTML file tags. they don't retain their value between form / page loads, like from validating or page 2

    another problem related we couldn't find away to change the text and appearance on the browse buttons beside the file widget. the file tag represents a UI control that is very specific to the browser. it is somehow handled natively and in a way that invokes the native file selector dialog.

    I think the only way to have true file selector control is to not use one, but then you get into complex Javascript widgets, or a file upload applet. Facebook seems to do it right somehow.

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2011, 10:55 AM
  2. count character in text file as input file
    By aNNuur in forum New To Java
    Replies: 7
    Last Post: 03-25-2010, 05:01 PM
  3. loading .properties file dynamically
    By nanaji in forum Advanced Java
    Replies: 3
    Last Post: 03-17-2009, 04:40 AM
  4. getting dynamically generated valus
    By abhiN in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 03-29-2008, 11:58 AM
  5. passing dynamically generated values
    By abhiN in forum Advanced Java
    Replies: 1
    Last Post: 01-20-2008, 04:21 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts