?
Solved

Copy field to another field web form

Posted on 2014-09-09
8
Medium Priority
?
331 Views
Last Modified: 2014-09-10
I am trying to build on online employment application.  I've got everything set but one item.  Part of the application process is they can upload a resume if they would like, the file field browses the file system so they can select a file.  Once selected it uploads with the form information they have provided.  I am trying to copy one field to another field within the form so when the data is saved, I know the name of the file they uploaded for their resume.  Everything works fine on explorer, google chrome, mozilla.  I can't get this to work on Safari, Macs or any mobile device.  Here is the code I am using to copy the original file field name to another hidden text field.    

<script>  
    var form = document.getElementById('form1');
form.elements.fle.onblur = function () {
    var form = this.form;
    form.elements.fle2.value = form.elements.fle.value;
};
    </script>

The file transfer and all other data are saved on every type of browser (including the mobile devices) the only thing not working is the name of the file they uploaded on the systems I mentioned before (to the hidden text field).  I hope I have provided enough information.  I am somewhat new at this web development thing and hoping someone can point me in the right direction.

Thank you in advance for any assistance.
0
Comment
Question by:rick123456789
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 40314748
function blr(f1,f2) {
     document.getElementById(f2).value = document.getElementById(f1).value;
}
should work across browsers
you can use onblur="blr('fle1','fle2')"
you need to give each input an id - which i'm not sure if you've done or not
input id="fle1" & input id="fle2"
0
 
LVL 34

Expert Comment

by:Slick812
ID: 40315037
greetings  rick123456789, , I am not sure that your Form element access with code -
     form.elements.fle2.value = form.elements.fle.value;

is at all correct for some browsers. For me if I know the "name" of a form element, I can just property it from the DOM FORM object, as in if names is "hidden1" and "text1"
form1.hidden1.value = form1.text1.value;

if you use the FORM elements array, you can get individual elements by NAME with -
   form1.elements.namedItem("hidden1").value;

However the FORM file upload INPUT is a Different setup than any other Input, and it's "File name" value is NOT available in some browsers for access by some javascripts.
But, On the SERVER side code you already get the UPLOADED file name, without any hidden input copy, as all file uploads are delivered with a "File Name" from the Operating System that they came from.
0
 
LVL 25

Accepted Solution

by:
dgrafx earned 2000 total points
ID: 40315062
something slick812 said prodded me into reading your post again - I believe I misunderstood ...

you are uploading a file
your file upload code on your backend will return the original filename - if asked
you are probably getting some useless temp filename when using form.fle
the syntax depends on the language you are using - what language are you using on the backend?

for ex:
https://www.google.com/?gws_rd=ssl#newwindow=1&q=how+to+return+the+uploaded+filename+in+php&spell=1
or
https://www.google.com/?gws_rd=ssl#newwindow=1&q=how+to+return+the+uploaded+filename+in+java
or
https://www.google.com/?gws_rd=ssl#newwindow=1&q=how+to+return+the+uploaded+filename+in+coldfusion
0
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 

Author Comment

by:rick123456789
ID: 40315276
Slick812,

php writes the information on server side to a text file that is downloaded and imported into a database at the main office.  Download and import is automated.
0
 

Author Comment

by:rick123456789
ID: 40315328
sorry previous post should have been addressed to "dgrafx"
0
 

Author Comment

by:rick123456789
ID: 40315371
Got it.  Thanks dgrafx.  I had to dump the java and go back server side with php.  Once I got it to write the file name via the php post all browsers work.
0
 

Author Closing Comment

by:rick123456789
ID: 40315372
Thanks again :-)
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 40315392
Glad it worked out!
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question