Multiple upload controls on page

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Multiple upload controls on page

Post by jmestep » Thu Mar 05, 2009 10:16 am

I'm customizing some admin pages where the client needs to upload images for some new custom fields. I've taken some of the code from digital files upload code, put it into a user control, and put that user control multiple times on the admin page with different id tags. It works fine as far as saving the url of the file to the correct field and uploading the file to the server.
But if I put the validation back on and the script to set the file uploaded name to the file name box, I run into problems. I know what the problem is, but I don't know how to fix it.
One of the problems is with the javascript to set the name into the text box- it has UploadFile. as the name of the control and I have an UploadFile1 and an UploadFile2. How can I get it to loop thru both of the controls? Here is the javascript:

Code: Select all

<script type="text/javascript" language="javascript">
            var lastName1="";var lastName2="";function setNames(){var a=document.getElementById("<%= UploadFile.ClientID %>").value;if(a.length>0){var b;var c=a.lastIndexOf("\\");if(c<0){c=a.lastIndexOf("/");if(c<0){b=a}else{b=a.substring(c+1)}}else{b=a.substring(c+1)}var f=document.getElementById("<%= UploadFileName.ClientID %>");if((f.value.length==0)||(f.value==lastName2)){b=b.replace(/ /g,"_");f.value=b;lastName2=b}}}
        </script>
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply