Hi, all.

I'm working on a form that would allow some arbitrary number of
documents to be uploaded at once. The idea is that by default, one set
of document fields appears, and there's a link that a user can click to
activate some javascript that would add another set of document fields.
I have this basically working. The new fields are named the same as the
old fields, and that works just fine, with Struts automatically making
those into array properties.

My question, though, is how to make it not look horrible. I've included
the JSP below, and as you can see, I have an invisible div that I clone
and insert into the DOM tree before the Submit button. What I want is
for the cloned portion to be added as additional table rows in the table
that Struts creates for the main form. Instead, the cloned portion ends
in a table inside of a single cell in the original form's table. How can
I write the JSP so that the cloned portion fits in nicely? Is this a job
for a new theme? Have I just taken the complete wrong approach?

Thanks,
Dan Allen

__________JSP below______________

<!DOCTYPE html PUBLIC 
        "-//W3C//DTD XHTML 1.1 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
        
<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %>

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
        <title>Policy Uploads</title>
        <s:head />
        <%-- The Javascript will simply multiply the HTML code generated
by Struts for us, and the identical fieldnames
             will cause Struts to see the form as working with indexed
properties. 
             See DocumentUploadAction.java --%>
        <script language="JavaScript">
                var fileCount = 1;
                var clonedNode = null;
                var insertLoc = null;
        
                function addFileToForm() {
                        if(fileCount >= 5) {
                                alert("Please upload files in batches of
five or less, in order to maintain reasonable response times.");
                                return;
                        }
                        clonedNode =
document.getElementById('cloneTarget').cloneNode(true);
                        clonedNode.style.display = ''; // The clone
target has display "none"; drop that attribute.
                        insertLoc =
document.getElementById('documentSubmitButton');
                        insertLoc.parentNode.insertBefore(clonedNode ,
insertLoc);
                        fileCount = fileCount + 1;
                }
        </script>
</head>

<body>
        <div id="cloneTarget" style="display: none">
                <s:file name="documentFiles" label="File"/>
                <s:select name="documentTypes" label="Type"
list="documentTypeChoices"/>
                <s:textfield name="documentNames" label="Name"/> (leave
blank to copy the name from the uploaded file)
        </div>
        <s:form id="docsForm" method="POST"
action="documentUpload_execute" enctype="multipart/form-data">
                <s:textfield name="policyId" label="Upload for Policy
#"/>
                <hr/>
                <s:file name="documentFiles" label="File"/>
                <s:select name="documentTypes" label="Type"
list="documentTypeChoices"/>
                <s:textfield name="documentNames" label="Name"/> (leave
blank to copy the name from the uploaded file)
                <s:submit id="documentSubmitButton"/>
        </s:form>
        <br>
        <hr>
        <a href="javascript:addFileToForm()">Click here</a> to add more
files to the upload.
</body>
</html>

-- 
This message may contain confidential, proprietary, or legally privileged 
information. No confidentiality or privilege is waived by any transmission to 
an unintended recipient. If you are not an intended recipient, please notify 
the sender and delete this message immediately. Any views expressed in this 
message are those of the sender, not those of any entity within the KBC 
Financial Products group of companies (together referred to as "KBC FP"). 

This message does not create any obligation, contractual or otherwise, on the 
part of KBC FP. It is not an offer (or solicitation of an offer) of, or a 
recommendation to buy or sell, any financial product. Any prices or other 
values included in this message are indicative only, and do not necessarily 
represent current market prices, prices at which KBC FP would enter into a 
transaction, or prices at which similar transactions may be carried on KBC FP's 
own books. The information contained in this message is provided "as is", 
without representations or warranties, express or implied, of any kind. Past 
performance is not indicative of future returns.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to