Results 1 to 2 of 2
- 08-27-2008, 03:52 AM #1
Member
- Join Date
- Aug 2008
- Posts
- 1
- Rep Power
- 0
Need some help bad, at wits end validating this form and keeping script.
Well, here goes. I am new to the whole java thing. To make a long story short, I was using frontpage before now, and got tired of the extensions not working all of the time. So, off to the wonderful world of scripts for me.
My site has a order page, where customers can fill out a form, and the results of that form are emailed to me, then that page sends you to a results page, and the variables are displayed in such a way that the customer can print the page and use it as a mailing label. So, this is what i came up with.
hoovershoerepair.com/menu.htm
I got the page to create a dynamic url, and i got the following page to display each variable where i wanted, but now I can't seem to figure out how to get the form to validate.. if it fails validation in the current configuration it still sends the form, and generates the second page.
Best I can think of, is there a way to get either the submit button to disappear until the form is valid, or is there a way to run the validation script on "submit" then if it passes, run the second script to generate the url, and lastly, post to the cgi script that generates my email?
---
Sorry if that makes no sense, web design isn't my strongest suit - though i am proud of what I have been able to come up with on my site. I was into photoshop and illustrator for a long time, but never learned much more than basic html... not much need for a shoe repairman, you know.
Any help would be HUGELY appreciated, if you would like me to post the java in the forum, rather than a link to the offensive page, please let me know as well. I have been trying to figure this out for about three days and have hit the wall.
--- scripts are as follows ---
-----Java Code:<script type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> ------ <SCRIPT language="JavaScript"><!-- var debug = false; // replace with: var debug = true; function thankYou(form) { form.redirect.value = 'shipping_confirmation.php' + '?' + escape('Action') + '=' + escape('Feedback') + '&' + escape('AFirstname') + '=' + getText(form.AFirstname) + '&' + escape('BLastname') + '=' + getText(form.BLastname) + '&' + escape('CAddress1') + '=' + getText(form.CAddress1) + '&' + escape('DAddress2') + '=' + getText(form.DAddress2) + '&' + escape('ECity') + '=' + getText(form.ECity) + '&' + escape('FState') + '=' + getText(form.FState) + '&' + escape('GZipcode') + '=' + getText(form.GZipcode) + '&' + escape('KWedecide') + '=' + getCheckbox(form.KWedecide) + '&' + escape('LHeeltips') + '=' + getCheckbox(form.LHeeltips) + '&' + escape('MToetips') + '=' + getCheckbox(form.MToetips) + '&' + escape('NMetaltoedot') + '=' + getCheckbox(form.NMetaltoedot) + '&' + escape('OLadieshalfsole') + '=' + getCheckbox(form.OLadieshalfsole) + '&' + escape('PLadieshalfsoleandheel') + '=' + getCheckbox(form.PLadieshalfsoleandheel) + '&' + escape('QMensheel') + '=' + getCheckbox(form.QMensheel) + '&' + escape('RMenshalfsole') + '=' + getCheckbox(form.RMenshalfsole) + '&' + escape('SMenshalfsoleandheel') + '=' + getCheckbox(form.SMenshalfsoleandheel) + '&' + escape('TMensfullsole') + '=' + getCheckbox(form.TMensfullsole) + '&' + escape('VRefinishwhiteshoes') + '=' + getCheckbox(form.VRefinishwhiteshoes) + '&' + escape('XNylontoeplate') + '=' + getCheckbox(form.XNylontoeplate) + '&' + escape('WNylonheelplate') + '=' + getCheckbox(form.WNylonheelplate) + '&' + escape('UShine') + '=' + getCheckbox(form.UShine) + '&'; if (debug) { location.href = form.redirect.value; return false; } return true } function getText(object) { return escape(object.value) } function getOption(object) { return escape(object.options[object.selectedIndex].text); } function getRadio(object) { for (var i = 0; i < object.length; i++) if (object[i].checked) return object[i].value; return ''; } function getCheckboxes() { var output = ''; for (var i = 0; i < getCheckboxes.arguments.length; i++) output += getCheckbox(getCheckboxes[i]) + escape(' '); return output; } function getCheckbox(object) { if (object.checked) return escape(object.value); else return ''; } //--></SCRIPT>
here's how the form is setup
Java Code:<form action="/cgi/gdform.cgi" method="POST" onSubmit="MM_validateForm('AFirstname','','R','BLastname','' ,'R','CAddress1','','R','ECity','','R','FState','' ,'R','GZipcode','','RisNum','IHomephone','','R','J Email','','R');return thankYou(this);return document.MM_returnValue"> <input type="hidden" name="subject" value="Order from Hoover Shoe Repair.com" /> <input type="hidden" name="redirect" value="shipping_confirmation.php" />
---
I use php on the confirmation page...
which prints the value of the variable on the page.Java Code:<?php print "".$_GET['AFirstname']; ?>
Probably not the most eloquent solution, but it was all i could come up with.
Thanks a MILLION!
-Pete
- 08-27-2008, 04:27 AM #2
Similar Threads
-
POI for delete excel record with keeping the existing macros
By Jay in forum Advanced JavaReplies: 0Last Post: 07-31-2008, 10:44 AM -
Validating email address!
By rameshraj in forum Advanced JavaReplies: 1Last Post: 02-18-2008, 09:39 AM -
validating selection list in struts!
By rameshraj in forum Web FrameworksReplies: 2Last Post: 02-13-2008, 01:21 PM -
Validating email address
By ravian in forum New To JavaReplies: 2Last Post: 12-21-2007, 08:42 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks