The ID in line 3 of the validation code should be "attachment "+i (without the 's').
Alert for description attachment
Collapse
X
-
Hey Acoder,Originally posted by acoderThe ID in line 3 of the validation code should be "attachment "+i (without the 's').
Now its working correctly. But one last thing that i got to add to it. I don't know if its possible but is there anyway to make it so it don't alert if no attachment nor description is filled out?
Thank you,Code:for (i = 1; i <= upload_number; i++) { description = document.getElementById("description"+i); attachment = document.getElementById("attachment"+i); if (attachment.value== ""){ alert("Please choose a attachment"); return false; } else if(description.value== "") { alert ("Please fill in the description for your attachment"); return false; } }
RachComment
-
Hey Acoder,Originally posted by acoderWould this be in the case where there's only one attachment or could there be more than one attachment all of which could be empty?
Well i am saying basically if a user did not choose an attachment nor a description that it would still let me submit instead of it asking for me to choose an attachment.beca use right now if someone does not choose an attachment nor writes a description they still have to put something therein order to click submit.
Thank you,
RachComment
-
I think you only need to check attachment1 then because the description is checked afterwards anyway. You can put an if statement around the whole validation code which checks that attachment1 is not empty:
Code:if (document.getElementById("attachment1").value != "") { for ... }Comment
-
Hey Acoder,Originally posted by acoderI think you only need to check attachment1 then because the description is checked afterwards anyway. You can put an if statement around the whole validation code which checks that attachment1 is not empty:
Code:if (document.getElementById("attachment1").value != "") { for ... }
That worked! Thank you, Thank you. I got one last question, well more asking an opinion. I am working on making it so users can view the attachments. One of my co-works suggested that i have a description link that they can click on to open the attachments on an "attachment " section that would hold all the links. An well i was going to do it where they see the description click on the description an it opens the attachment they want. An well i am not sure which way would be the better way to go about it.I was thinking since i am using the ID to only show the attachments associate with that ticket that i can't see the point of an attachments section. But was opening maybe you could point out why it would be a good idea or if it would be a good idea (he is on vacation so i have no way of asking him for a while). An i also i been thinking they should be able to download attachments to there computer, but i have no clue where i would begin on letting the user. But if you could explain a good way to do this i would really appreciate it :).
Thank you again for all the help :),
RachComment
-
Is this on the input page? The attachment comes from the local computer and when you submit, it is submitted to the server. If you want to view it, you will need server-side code because JavaScript doesn't allow access to local files. So I suggest you start a new thread in the Coldfusion forum.
PS. glad to see that the main problem is solved though.Comment
-
Hey Acoder,
Yes thank you for helping me solve the main problem. I am having no trouble displaying the attachments i am more asking about what would be the best way to make previously submitted attachments viewable to the user. Right now i am working on making previously entered data viewable. An well i am trying to think of the best way to make it viewable. Meaning right now the way it works is the description the user gives the file will appear on the form (the viewable form). An basically they click on the description an they can see the attachment. My fellow co-worker suggested doing it where there is a link an they click on and it an it takes them to an attachments page. An then on the attachments page they see all the attachments that was added an then they can click on it. I am just not sure what would be the best way to display it for the user.
Thank you,
RachComment
-
If it's for previous (already uploaded) attachments, then that should be possible to display with the help of JavaScript.
The best way depends on what suits the user the best. You could just display all attachments without having to click on any links. If that could end up cluttering the page, you could display it on the same page in a div (not a pop-up window). This would prevent having to open a new window to view the attachments. If you're thinking of taking this approach, this is now a different problem to the original, so I suggest you start a new thread for this question.Comment
-
Hey Acoder,Originally posted by acoderIf it's for previous (already uploaded) attachments, then that should be possible to display with the help of JavaScript.
The best way depends on what suits the user the best. You could just display all attachments without having to click on any links. If that could end up cluttering the page, you could display it on the same page in a div (not a pop-up window). This would prevent having to open a new window to view the attachments. If you're thinking of taking this approach, this is now a different problem to the original, so I suggest you start a new thread for this question.
Yeah i think all probably leave all the attachments on the same page. Just have a hard time seeing the point of putting it on a different page when its only going to show the ones uploaded for that particular ticket. But thank you again for all the help :),
RachComment
-
Hey Acoder,Originally posted by acoderThere is a point in not showing all the attachments on the same page at once. For example, if they clutter up the page or take a long time to load, then it makes sense to not show them initially and only show when requested.
Oh i was not meaning there was no point to it. Just for the project i am working on i can not see someone uploading so many attachments to the point where they need there own page. Well atleast that is what i thought until i got some recent news on something else they want done. So although i can not see them uploading so many attachments i guess it is possible an i know i been playing around with the attachments an well i have seen 20 on a page an it don't look to good. But i think i am going to add the attachments page an let them choose what attachments they want open that way. But thank you again for all your help :)
RachComment
Comment