Current location: Hot Scripts Forums » General Web Coding » JavaScript » Need script to close after submit and add cookie


Need script to close after submit and add cookie

Reply
  #1 (permalink)  
Old 08-06-04, 12:33 PM
Randyd Randyd is offline
New Member
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow Need script to close after submit and add cookie

Can someone help? I have a form that uses a javascript that validates each field when the submit button is clicked. The form does not close after being submitted. Can some code by added to the submit button. I would like the form to close automatically after the submit button is clicked but I don't know how. I also need a java script to add a cookie to their computer so the form does not come up after they have submitted it. Can that all be accomplished with one script? This is what I am using now. I got it at javascript.internet.com I can dump it if there is something better to use.

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea") &&
tempobj.value=='')||(tempobj.type.toString().charA t(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUppe rCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return true;
}
// End -->
</script>


Then in the form tags I'm using:

<form onSubmit="return checkrequired(this)" onSubmit="return submitForm()" action="mailto:myaddress@xxxx.com?subject=My Subject" name="My Form" method="post" enctype="text/plain">
Reply With Quote
  #2 (permalink)  
Old 08-11-04, 12:32 PM
dwoody dwoody is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Close window

I am not sure exactly what you are looking for with the cookies and that but if you want your users browser to close when they click the submit button just add:

;window.close()

:to your onSubmit line.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
submit link in cookie prenaud JavaScript 0 07-28-04 10:30 AM


All times are GMT -5. The time now is 10:29 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.