Click to See Complete Forum and Search --> : Shipto same as Billto - help?


kjohn
06-18-2003, 10:34 AM
Hi there, this is my first time to this board! Just wanted to test how fast the reply is by asking a question here...

Can someone tell me how to get a Shipto address to fill in automatically when a checkbox is checked and the billto information has already been filled in?

I'm new to javascript so don't laugh at my first attempt:

function Shipto() {
if (document.checkout.same.value = true)
{document.checkout.shipto.value = document.checkout.billto.value
document.checkout.shiptocity.value = document.checkout.billtocity.value
document.checkout.shiptostate.value = document.checkout.billtostate.value
document.checkout.shiptozip.value = document.checkout.billtozip.value}


<input type="checkbox" name="same" value="true" onClick="Shipto()">

Thank you for your help!!!

Katie

Jona
06-18-2003, 11:06 AM
function Shipto() {
if (document.checkout.same.value == "true")
{document.checkout.shipto.value = document.checkout.billto.value
document.checkout.shiptocity.value = document.checkout.billtocity.value
document.checkout.shiptostate.value = document.checkout.billtostate.value
document.checkout.shiptozip.value = document.checkout.billtozip.value}


<input type="checkbox" name="same" value="true" onClick="Shipto()">


Jona

kjohn
06-18-2003, 11:16 AM
I'm still not getting it to work... here is my page:
http://www.surgimark.com/html/checkouthtm.htm

I'm also not getting the validate form to work either.

Also, while we're at it...

I want the creditcard text areas(number, month and year) to all be dimmed until a person picks visa/mastercard,

then I want those to be able to be validated as well.. (that they are filled in)

Whoever is willing to help my poor soul... God Bless YOU!!!!
:)

Katie <---- newbie

Jona
06-18-2003, 11:18 AM
I get an error 404 when trying to view that page.

Jona

kjohn
06-18-2003, 11:19 AM
sorry try it now

Jona
06-18-2003, 11:26 AM
You forgot the last squigly brace:


function Shipto() {
if (document.checkout.same.value == "true")
{document.checkout.shipto.value = document.checkout.billto.value
document.checkout.shiptocity.value = document.checkout.billtocity.value
document.checkout.shiptostate.value = document.checkout.billtostate.value
document.checkout.shiptozip.value = document.checkout.billtozip.value;}
}


As for the rest of it, you should try having all elements in the form disabled by default, and then when the type of card is chosen, enabled them. Then validate the form. You might want to use Regular Expressions to validate the form, because with the code you have right now, the person can just put a space in there and it will say something is in the field.

Jona

kjohn
06-18-2003, 11:31 AM
Well, apparently theres more than that wrong.... it is giving me this error:

Error 1005 Expression expected (points to this line: </script>)
line 135

and how do I "use regular expressions" to validate the form?

sorry I am very very very new to this...

Thanks for your help Jona.

Katie

Jona
06-18-2003, 11:38 AM
Take out all of the <!-- and //--> parts out of your Javascript code. Not only do you not need them, they occasionally cause errors. Make sure you update the link as I help you, otherwise we'll go through a whole ordeal of me having to tell you to update the page every time I reply. ;)

Jona

kjohn
06-18-2003, 11:40 AM
Apart from all my bad scripting,

why is the broswer trying to download the file autoformsend.cfm instead of sending the information to it?

Katie

kjohn
06-18-2003, 11:43 AM
k sorry, I updated it... duh. hehe

still same error after taking those out..

Jona
06-18-2003, 11:43 AM
Originally posted by kjohn
Apart from all my bad scripting,

why is the broswer trying to download the file autoformsend.cfm instead of sending the information to it?


I don't get any download dialogs when I load the page...

Jona

Jona
06-18-2003, 11:47 AM
OK, you forgot to put the last brace on this function, as well:


function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


Jona

kjohn
06-18-2003, 11:48 AM
I actually found that just a second ago and fixed it...


Okay, so it is working correctly in the sense that there are no errors, however there are no pop-up windows when you click Place Order without filling in anything in the fields....

Jona
06-18-2003, 11:51 AM
Originally posted by kjohn
[H]owever there are no pop-up windows when you click Place Order without filling in anything in the fields....

Yes, this is because your form tag. It should look like this:


<FORM METHOD="post" ACTION="autoformsend.cfm" name="checkout" onsubmit="return validate();">


Jona

kjohn
06-18-2003, 11:54 AM
oooohhh.. you're so good. hehe

Thank you, I'll post again when I have my next problem.

Thanks Jona.

Katie

Jona
06-18-2003, 11:55 AM
Try putting a space in all of the text boxes and then submitting the form.

Jona

kjohn
06-18-2003, 11:56 AM
hmmmm still no pop up windows... w/ or w/out spaces...

Jona
06-18-2003, 11:59 AM
That is because when you click the submit button, you have Javascript that executes before the onsubmit is called; therefore you are redirected to the home.htm page instead of the form processing page in ColdFusion (the URI is the same as that of the form's action). Try this instead:


<input type="submit" name="Submit" value="Place Order">


Jona

kjohn
06-18-2003, 12:04 PM
Ok, you got the pop up windows working....

Now here is what I get when all fields have an entry...

FILE DOWNLOAD

Some files may harm your computer.. blah blah blah

File Name: Autoformsend.cfm
File Type: Macromedia Cold Fusion

blah blah

would you like to open the file or save it to your computer?



That makes no sense...

Katie

Jona
06-18-2003, 12:07 PM
Hmm.... I don't get that error. What browser/version are you using? I get an error 404 because "thankyou.cfm" does not exist, but it submits the form fine...

Jona

kjohn
06-18-2003, 12:10 PM
I am running Windows XP, and I don't know why you are getting a thankyou.cfm because I haven't created a thankyou.cfm ..? I made it redirect you to another htm page called homehtm.htm and actually that will be a thank you page instead of a home page...


Katie

kjohn
06-18-2003, 12:12 PM
Hold on, I think my server is adjusting things...

kjohn
06-18-2003, 12:14 PM
Okay I am now getting the same 404 error you are.

How do u know it is trying to take you to thankyou.cfm?
My browser still says http://www.surgimark.com/html/autoformsend.cfm

I don't see anything about thankyou.cfm


Katie

Jona
06-18-2003, 12:14 PM
The form does submit if you put spaces in the form fields. To validate the form better, you need to use Regular Expressions.

Jona

kjohn
06-18-2003, 12:20 PM
Ok... if you want to tell me how that would be great... (Regular expressions)

Can you however start at this page:
http://www.surgimark.com/html/orderhtm.htm

I want the variables from that page to be sent to the next one we were just working on, and then when the form submits, I want to be able to see all the variables in the email.

So far I have been getting our tests....

Katie

kjohn
06-18-2003, 12:31 PM
I have now put the following code in at my <FORM> tag:

<FORM METHOD="post" ACTION="autoformsend.cfm" name="order" onsubmit="return validate();MM_goToURL('parent','http://www.surgimark.com/html/thankyouhtm.htm');return document.MM_returnValue">

It isn't redirecting to the page I want...
I don't want it on the button cuz it won't read the validate(); function....

Jona
06-18-2003, 12:31 PM
Originally posted by kjohn
Ok... if you want to tell me how that would be great... (Regular expressions)

To check and make sure only letters are entered, use this:


var re = /^[a-zA-z]$/
if(re.test(f)){ // continue;
} else { return false; }


You can see the online reference to RegExps here: http://devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/regexp.html

Originally posted by kjohn
I want the variables from that page to be sent to the next one we were just working on, and then when the form submits, I want to be able to see all the variables in the email.

This requires server-side code. You can use CF to retrieve the values from one posted form onto another form and yet, onto another form if you like. Do you know CF? (CF stands for ColdFusion.)

Jona

Jona
06-18-2003, 12:34 PM
Originally posted by kjohn
I have now put the following code in at my <FORM> tag:

<FORM METHOD="post" ACTION="autoformsend.cfm" name="order" onsubmit="return validate();MM_goToURL('parent','http://www.surgimark.com/html/thankyouhtm.htm');return document.MM_returnValue">

It isn't redirecting to the page I want...
I don't want it on the button cuz it won't read the validate(); function....

Instead of using Javascript for that, you should set up your autoformsend.cfm file to process the form and say whatever the tahnkyouhtm.htm file says. Take off the MM_goToURL() function. Instead use the ACTION="autoformsend.cfm" one. You can't have it redirect to two different pages at the same time, it's not possible; however if you'd like, you can make your autoformsend.cfm file automatically redirect to the thankyouhtm.htm file after it processes the form using onload = function(){location.href="thankyouhtm.htm";} in your head tag (in a <script> tag).

Jona

pyro
06-18-2003, 12:37 PM
Originally posted by Jona
var re = /^[a-zA-z]$/

That should be:

var re = /^[a-zA-Z]$/

Jona
06-18-2003, 12:40 PM
Originally posted by pyro
That should be:

var re = /^[a-zA-Z]$/

Freaking typos... :p Thanks, pyro. ;)

Jona

kjohn
06-18-2003, 12:41 PM
Unfortunately I didn't write the .cfm script, our server did.
I don't know CF enough to write my own.

Is there a way to get it to redirect from javascript?

I don't think we are going to have people trying to enter spaces for their information. We are dealing with hospitals that are ordering surgical products, so they know it is important to have their information. I just wanted a warning to come up in case they forgot to enter something...

pyro
06-18-2003, 12:41 PM
Yep, also out of curiosity, what is this validating? It certanly doesn't allow much...

Jona
06-18-2003, 12:43 PM
Originally posted by kjohn
Unfortunately I didn't write the .cfm script, our server did.
I don't know CF enough to write my own.

Is there a way to get it to redirect from javascript?


Do you have access to any other type of server-side languages such as Perl, PHP or ASP?

You can't completely rely on Javascript. Approximately 13% of your visitors have it disabled. The site should work even with Javascript disabled.

Jona

kjohn
06-18-2003, 12:45 PM
Also, we have 2 different forms that are sending information to this script, so we need to be able to redirect from the webpage, that way we don't have the user sent to the wrong thank you page. (Each one needs to say something different)

Jona
06-18-2003, 12:45 PM
Ugh, pyro you're beating me up! :p Let me re-do that RegExp...


var re = /^[a-zA-Z]{4,}$/


At least 4 or more characters must be in the field and it must start with and end with and only have in it letters a though z, both capital and lower case.

Anything else? ;)

Jona

Jona
06-18-2003, 12:46 PM
Originally posted by kjohn
Also, we have 2 different forms that are sending information to this script, so we need to be able to redirect from the webpage, that way we don't have the user sent to the wrong thank you page. (Each one needs to say something different)

Again, there is server-side code that should do this--not Javascript.

Jona

kjohn
06-18-2003, 12:47 PM
They said that the platform we are on won't support PERL or ASP for some reason.....

The main people that will be visting our site are hospital purchasing agents as I said earlier... so I am guessing a hospital would have current computer systems with javascript enabled?

If they for some reason aren't able to order online, they can do it the normal way, by calling us. That is how all ordering is being done currently.

Jona
06-18-2003, 12:49 PM
It may be that their systems are updated, but they may have Javascript disabled for security. So there you have another problem. That is why your sites should always work without Javascript. Does your server support PHP?

Jona

kjohn
06-18-2003, 12:51 PM
Let me ask them...

Also they might be nice and not charge me for cutting a pasting one line of code if I could give them the line for redirecting based upon with orderform was used...

(they said if I want the script i have to buy it for like 125 dollars)

kjohn
06-18-2003, 12:55 PM
Okay I gave them a call and they actually said that PERL is supported however when I tried to use a PERL script before, I had used a unix one instead of an NT one.

Anyone know where I can find a simple NT perl mail script? I will need to customize if for what I am trying to do here...

Jona
06-18-2003, 12:58 PM
I made a CGI script that processes a form and emails it yesterday, but it is running on a Linux server... I don't know if that would make too much of a difference, but if you want the source code, I'd be happy to give it to you.

Jona

kjohn
06-18-2003, 01:03 PM
Linux... I dont know if that would work... he said it has to be windows based...

Jona
06-18-2003, 01:07 PM
The script should work on any server, but I haven't tested it on an NT server... Trying never heart anyone. ;)

Jona

kjohn
06-18-2003, 01:12 PM
Ok, go ahead and post it.

I also downloaded one called MailForm that is windows based as well.. I'll see which one works better.


Jona, do you think you could tell me why my variables arent being passed from my first orderform to my second?
I'm not seeing the variables in my email from the first form.

Here's the url for the first form:
http://www.surgimark.com/html/orderhtm.htm

kjohn
06-18-2003, 01:17 PM
The mail form that I thought I had found is only a sample, they won't give you the source code unless you pay $99

I think I'll try your script thank you! :)

Katie

Jona
06-18-2003, 01:21 PM
Originally posted by kjohn
Jona, do you think you could tell me why my variables arent being passed from my first orderform to my second?
I'm not seeing the variables in my email from the first form.

Here's the url for the first form:
http://www.surgimark.com/html/orderhtm.htm

There's not much of a point in you giving me the URL to a server-side processed page. :p I can't see any of the ColdFusion code (I don't know CF, but I can probably help you figure it out some).

Here is the code:

process.cgi

#!/usr/local/bin/perl

use CGI qw{:cgi};

#The below gets the form data from the previous page. This assumes that
# your form elements are named fn, ln, em, and rat.

my $name = param('fn');
my $name2 = param('ln');
my $email = param('em');
my $rating = param('rat');

# this is a function called "Mail"
sub Mail
{
($to, $from, $subj, $body) = @_;
# change the below value to the location of sendmail on your server
$mailprog = "/usr/sbin/sendmail";
open(MAIL, "| $mailprog -t ");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subj\n";
print MAIL $body;
print MAIL "\n";
}

#The below code calls the above function (or sub) and executes it with the set
# variables. You can change this as you like, it's quite self-explanatory
Mail("you\@yoursite.com", $email, "From your site", "You have just received a rating from someone. Here is their information:\n\nName: $name $name2\nEmail: $email\nRating of your site: $rating");

#Start printing HTML
print <<END;
Content-Type: text/html\n\n
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test</title>
<style type="text/css">
<!--
body{background-color:#c0c0c0;
overflow:hidden;}
-->
</style>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="dan_gabbard@anadarko.com">
<meta name="generator" content="AceHTML 5 Freeware">
</head>
<body><p>
Name: <b>$name $name2</b><br>
Email: <b>$email</b><br>
Rating: <b>$rating</b>
</p>
</body></html>
END


testforum.htm (The file that submits the form.)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test</title>
<style type="text/css">
<!--
body{background-color:#c0c0c0;
overflow:hidden;}
-->
</style>
</head>
<body>

<form name="form1" action="../cgi-bin/process.cgi" method="POST">
First Name<br>
<input type="text" name="fn" size="40" maxlength="256"><br>
Last Name<br>
<input type="text" name="ln" size="40" maxlength="256"><br>
Email Address<br>
<input type="text" name="em" size="40" maxlength="256">
<b></b>
<br><br><br>
Did you like my web site? Did you find what you were looking for? Let me know.<br>
<input type="radio" name="rat" value="Yes"> Yes<br>
<input type="radio" name="rat" value="No"> No<br>
<input type="radio" name="rat" value="Maybe"> Maybe<br>
<input type="submit" value="Submit">
<input type="reset" value="Clear Form">
</form>
</body>
</html>


Jona

kjohn
06-18-2003, 01:26 PM
I just meant to look at the page and see if my scripting is correct in sending the variables to the second part of the form...??? Because when I look at my email, I am not getting the variables from the first form..


This is going to sound really dumb, but what is the difference between a "windows based" mail script and a "unix" or other based?

I found another one that looks good, but I can't tell if it is "windows" based... I'm confused...:confused:

Katie

kjohn
06-18-2003, 01:30 PM
Jona...

I have no idea what I would do with the script you just posted...

I think that's too advanced for me. I'm taking baby steps here...

*sigh* I need to go to school and learn this stuff thoroughly instead of trying to just teach it all to myself. I am missing big chunks of information here and there, even though I know a lot. Gets very frustrating. Probably for you poor people too who have to attempt to help me. LOL

Katie

Jona
06-18-2003, 01:33 PM
Upload the testforum.htm file to your site, and upload the process.cgi script into your cgi-bin folder (in the public_html folder). If you upload testforum.htm in a new folder (e.g., public_html/testing/ for example) don't modify it; but if you upload it to the public_html/ folder, change the form tag to this:


<form name="form1" action="cgi-bin/process.cgi" method="POST">


I don't know what the difference is either. :p Try uploading the files and see if the script works. If it doesn't work, make sure your first line is right according to the "path to perl." If you have a control panel, you should have somewhere where it says "path to perl" and "path to sendmail." You should set both of those. First line: path to perl, and then I have a comment in my code that shows where to put the path to sendmail.

Jona

Jona
06-18-2003, 01:37 PM
Originally posted by kjohn
*sigh* I need to go to school and learn this stuff thoroughly instead of trying to just teach it all to myself.

I've taught myself everything I know... Well, I did get some help from these forums (I'm not taking that away from anyone here!) but most of it I learned on my own. ;)

Jona

kjohn
06-18-2003, 01:45 PM
Well that is encouraging cuz you do know a lot :)

Heres what I get when I did all that:

500 Server Error
The server encountered an error and was unable to complete your request.
Message: Shell E:/websites/SurgiMark/cgi-shl/process.cgi does not exist or is not executable.

Please contact the server administrator at webmaster@webstercorp.com and inform them of the time the error occured, plus anything you know of that may have caused the error.

Also, please return to the referring document and note the hypertext link that led you here.

kjohn
06-18-2003, 01:50 PM
Be back in 1 hour, going to lunch.

Hope to talk to you more about this stuff!
Thank you!

Katie

Jona
06-18-2003, 01:50 PM
OK, can you give me a link, please?

Jona

kjohn
06-18-2003, 03:11 PM
http://www.surgimark.com/html/testforum.htm

Jona
06-18-2003, 03:42 PM
Okay. Do you have an online control panel? If so, login and go to the public_html/cgi-bin/ folder. Find process.cgi and change its permissions to 755 (or 0755 if there are four numbers). If you are using FTP, CHMOD the file to 755 as you upload it.

Jona

kjohn
06-18-2003, 04:04 PM
Remember, this isn't a Unix server. CHMOD settings can only be changed in Unix.

My server's customer service agent said the permissions that are defaulted are fine.

Jona
06-18-2003, 04:15 PM
Originally posted by kjohn
Remember, this isn't a Unix server.

lol, I'll have to remember that. :p

OK, what is your path to Perl? usr/bin/local/perl or usr/bin/perl? And for Sendmail? usr/bin/sendmail?

Jona

kjohn
06-18-2003, 04:43 PM
usr/bin/perl and usr/bin/sendmail I believe...

Right now I am trying a script called Form2mail... hope it works... we'll see.

I'm trying to find where in the script I can change the redirect URL..

Jona
06-18-2003, 04:46 PM
Well if you need any help, just ask. ;) You can also post in the CGI forum...

Jona

kjohn
06-18-2003, 04:52 PM
Crap, can you tell me why all of a sudden my "shipto check box" won't automatically fill in? I didn't change a thing..??

Jona
06-18-2003, 04:53 PM
Originally posted by kjohn
Crap, can you tell me why all of a sudden my "shipto check box" won't automatically fill in? I didn't change a thing..??

I don't think it ever did, did it? Post the link again and I'll take a look.

Jona

kjohn
06-18-2003, 04:58 PM
GRRRR... I'm so angry.

After all this work, my bill to and ship to stopped working, and I STILL can't get my information emailed to me correctly through this form.....


7 hours gone. Oh well, at least I'm getting paid for it.

*sigh*

Jona you willing to stick with me to try and figure this out?
Or would u rather I go to CGI forum?

Katie

kjohn
06-18-2003, 04:59 PM
http://www.surgimark.com/html/checkouthtm.htm


Yes, this whole original thread was to figure that out.. We did get that working....


Katie

Jona
06-18-2003, 04:59 PM
I've helped thus far, and I'm willing to help until the job is finished. ;) But if you'd like to post in the CGI forum you may do so.

Jona

Jona
06-18-2003, 05:04 PM
Try using this new function:


function Shipto(s, f) {
if(s.value=="true"){
f.shipto.value = f.billto.value;
f.shiptocity.value = f.billtocity.value;
f.shiptostate.value = f.billtostate.value;
f.shiptozip.value = f.billtozip.value;}
}


And your checkbox should look like this:


<input type="checkbox" name="same" value="true" onClick="Shipto(this, this.form);">


Jona

kjohn
06-18-2003, 05:08 PM
That worked, thank you..

Well I guess I will go start a new thread in the cgi forum..

You are more than welcome to come there and continue to help me :)

I just really want to get this Mail2Form working correctly...
This server my company has is horrible. They want to charge me because I keep calling to ask questions...

If I can get this working, I won't need their help.

Thanks Jona for all your help.

Katie

Jona
06-18-2003, 05:15 PM
I will continue to help you. ;)

Jona

kjohn
06-18-2003, 05:50 PM
Thanks Jona :) What a great friend you are becoming. hehe

I posted on the CGI board.

Katie

Jona
06-18-2003, 05:51 PM
You're welcome. ;)

Jona