Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-23-2002, 06:20 PM   PM User | #1
emma85
New Coder

 
Join Date: Aug 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
emma85 is an unknown quantity at this point
validation

hi

I'am lookin for a javascript that creates a form that needs to be filled in before the user can download a specific file from my site.

any of you know where I can find such script?


happycrappy
/Emma
emma85 is offline   Reply With Quote
Old 08-23-2002, 07:54 PM   PM User | #2
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
What would be the content of this form?
Mr J is offline   Reply With Quote
Old 08-24-2002, 10:13 AM   PM User | #3
emma85
New Coder

 
Join Date: Aug 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
emma85 is an unknown quantity at this point
Quote:
Originally posted by Mr J
What would be the content of this form?
just information about/from the user: name, address, ph, e-mail, and such...

/e
emma85 is offline   Reply With Quote
Old 08-24-2002, 07:09 PM   PM User | #4
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
The following is an example I have on my site at:

http://www.huntingground.freeserve.c...s/validate.htm

It really depends on the layout of your form as to how the script will be written.
If you need any more help let me know, I will where I can....help

<SCRIPT>
<!--
function check(){
var correct = true

if (document.Validate.name.value == ""){
correct = false; alert("Please Enter Your Name?")
}

if (document.Validate.email.value == ""){
correct = false; alert("Please Enter Your E-Mail Address?")
}

if(document.Validate.email.value.indexOf("@")==(-1)||document.Validate.email.value.indexOf(".")==(-1)){
correct=false; alert("Invalid email address")
}

if (document.Validate.comment.value == ""){
correct = false; alert("And Your Message Is?")
}
// Three button example
if(document.Validate.subject[0].checked==false&&document.Validate.subject[1].checked==false&&document.Validate.subject[2].checked==false){
correct=false;alert("Please select a language.")
}
// Two button example
if(document.Validate.number[0].checked==false&&document.Validate.number[1].checked==false){
correct=false;alert("Please select a number.")
}

if (correct){
alert("Thank you I will reply as soon as possible.")
}
return correct
}
//-->
</SCRIPT>

Add onsubmit="return check()" to the opening form tag

Below is the form that I have used for the above example.

<form name=Validate onsubmit="return check()">
<P>Name <input type=text name=name>
<P>E-Mail <input type=text name=email>
<P>Comment<Textarea name=comment></textarea>
English<INPUT type="radio" name="subject" value="English">
French<INPUT type="radio" name="subject" value="French">
Other<INPUT type="radio" name="subject" value="German">
One<INPUT type="radio" name="number" value="One">
Two<INPUT type="radio" name="number" value="Two">
<input type=submit value=Submit>
</form>
Mr J is offline   Reply With Quote
Old 08-25-2002, 11:06 AM   PM User | #5
emma85
New Coder

 
Join Date: Aug 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
emma85 is an unknown quantity at this point
hey,
okay, thanks! that form is okay.
but.
my next prob is that I want the user to be able to download a file from my site, after filling the form. if the person didn't fill the form, he can't download.
but maybe that requires some sort of cgi-stuff?
what you think?
/emma
emma85 is offline   Reply With Quote
Old 08-25-2002, 12:31 PM   PM User | #6
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
What sort of file and in connection with what?
Mr J is offline   Reply With Quote
Old 08-25-2002, 04:36 PM   PM User | #7
emma85
New Coder

 
Join Date: Aug 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
emma85 is an unknown quantity at this point
Quote:
Originally posted by Mr J
What sort of file and in connection with what?
In this case it's a pdf-file, but what did you mean by 'in connection with what'?
/e
emma85 is offline   Reply With Quote
Old 08-25-2002, 06:01 PM   PM User | #8
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
I meant was the file to be downloaded like a print off of the filled in form or, a seperate file altogether.


To download files from a website you can place the files in .zip
then put a link to that zip
Mr J is offline   Reply With Quote
Old 08-27-2002, 12:46 PM   PM User | #9
emma85
New Coder

 
Join Date: Aug 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
emma85 is an unknown quantity at this point
Quote:
Originally posted by Mr J
I meant was the file to be downloaded like a print off of the filled in form or, a seperate file altogether.


To download files from a website you can place the files in .zip
then put a link to that zip

its a separate file.
I basically know how to put a file on my page. but take a look on this page:
http://www.beeweeb.com/download/dlmapper2k.shtml

that's what I wanna do: first fill in a form. then download - if the form was correctly filled, that is!

happycrappy
/emma
emma85 is offline   Reply With Quote
Old 08-27-2002, 07:04 PM   PM User | #10
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
To download a file, first place it in a zip file then, you want a link to that zip file:


<A HREF="yourzipname.zip">Download this file</A>
Mr J is offline   Reply With Quote
Old 08-28-2002, 02:22 PM   PM User | #11
emma85
New Coder

 
Join Date: Aug 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
emma85 is an unknown quantity at this point
Quote:
Originally posted by Mr J
To download a file, first place it in a zip file then, you want a link to that zip file:


<A HREF="yourzipname.zip">Download this file</A>

okay! thanx for your help.
but. hmm. I guess I can't explain what I mean. cause that part I quoted above, I understand! That is not the problem.
but hey, we can't have it all. but I'll search! /e
emma85 is offline   Reply With Quote
Old 08-28-2002, 03:05 PM   PM User | #12
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
Do you mean that when you press the submit button, and the form is correctly filled in, a file automatically downloads?
Mr J is offline   Reply With Quote
Old 08-28-2002, 03:06 PM   PM User | #13
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
Or go to a page where the download links are?
Mr J is offline   Reply With Quote
Old 08-28-2002, 05:32 PM   PM User | #14
emma85
New Coder

 
Join Date: Aug 2002
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
emma85 is an unknown quantity at this point
Quote:
Originally posted by Mr J
Or go to a page where the download links are?

you got it!

:-)
emma85 is offline   Reply With Quote
Old 08-29-2002, 02:38 PM   PM User | #15
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
See if this works

Change the opening FORM tag for the following

<form name=Validate method="GET" ACTION="http://www.yoursite.co.uk/yourpage.htm" onsubmit="return check()">


The above includes the METHOD and ACTION attributes.

Change the ACTION path to that of your page.

I think it has to be an absolute path as well.
Mr J is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:56 AM.


Advertisement
Log in to turn off these ads.