473,651 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Issue - onSubmit canceling Action

Im new at Javascripting and jumped in the ocean and Im a little lost,
I am trying to get a form to do 2 things:

1) write a cookie (actually several cookies)
2) submit the information to a php file

If the site is coded for one of the commands (either one) the command
follows the submit. I have tried various ways to recode the form but
for some reason I can't make both happen on submit; depending on which
variable is first I either get a nice cookie or php return
confirmation.

The goal is to utilize the cookie on a second form to personalize the
page and to offer verification; I am open to losing the php on the
first form and sending all the information from both forms to a 3rd
page verification form with the cookie, but that is a totally
different problem.

Any suggestions?

<form name="freeform" onSubmit="
if(freeform.fir st_name.value.l ength != 0) {
var expdate = new Date ();
expdate.setTime (expdate.getTim e() + (24 * 60 * 60 * 1000));
SetCookie('Firs tName', freeform.first_ name.value, expdate);
SetCookie('Last Name', freeform.last_n ame.value, expdate);
SetCookie('Addr ess', freeform.addres s.value, expdate);
SetCookie('City ', freeform.city.v alue, expdate);
SetCookie('Stat e', freeform.state. value, expdate);
SetCookie('ZipC ode', freeform.zipcod e.value, expdate);
SetCookie('Birt hMonth', freeform.birthm m.value, expdate);
SetCookie('Birt hDay', freeform.birthd d.value, expdate);
SetCookie('Birt hYear', freeform.birthy y.value, expdate);
SetCookie('Area code', freeform.areaco de.value, expdate);
SetCookie('Phon ethree', freeform.phonet hree.value, expdate);
SetCookie('Phon efour', freeform.phonef our.value, expdate);
SetCookie('Send erEmail', freeform.sender _email.value,
expdate);
return false;
} else {
alert('Please fill in all the form fields.');
return false;
}">
<form method="post" action="process .php">
<input type="hidden" name="submit_ch eck" value="1" >
<!--After Form my submit button:-->

<input name="submitBut ton" type="image" id="submitButto n" src="images/
submitbutton.jp g"; />
Feb 21 '08 #1
3 1565
Removing all these cookies is most likely a good idea, but I still
need the data sent php and nest the cookie data. Right now this
javascript only sends the cookie and does not process the php file..

<form name="freeform" method="post" action="process .php" onSubmit="
if(freeform.fir st_name.value.l ength != 0) {
var expdate = new Date ();
expdate.setTime (expdate.getTim e() + (24 * 60 * 60 * 1000));
SetCookie('Firs tName', freeform.first_ name.value, expdate);
SetCookie('Send erEmail', freeform.sender _email.value,
expdate);
return false;
} else {
alert('Please fill in all the form fields.');
return false;
}">
<input type="hidden" name="submit_ch eck" value="1" >

Thanks.

On Feb 21, 6:00*pm, Joost Diepenmaat <jo...@zeekat.n lwrote:
Don't use so many cookies. There's a (fairly small) limit on how many
cookie data must be stored by a browser.
Feb 22 '08 #2
bonus <tb****@comcast .netwrites:
Removing all these cookies is most likely a good idea, but I still
need the data sent php and nest the cookie data. Right now this
javascript only sends the cookie and does not process the php file..
That's because return()ing false from onsubmit prevents the submit. You
should return true when you want the submit to process.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Feb 22 '08 #3
Joost Diepenmaat <jo***@zeekat.n lwrites:
bonus <tb****@comcast .netwrites:
>Removing all these cookies is most likely a good idea, but I still
need the data sent php and nest the cookie data. Right now this
javascript only sends the cookie and does not process the php file..

That's because return()ing false from onsubmit prevents the submit. You
should return true when you want the submit to process.
Also, this script does *not* send cookies. It only sets them. Cookies
are only sent when a request to the server is made and your script does
not make a request (since it blocks the submit)`.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Feb 22 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2978
by: greg brant | last post by:
i have a form made up of 2 file inputs and a submit button.. the imputs are to upload images, namley jpeg's for a e-greatings thing im working on. this only works with jpegs so i have a script that will check the value of the imput tag to make sure it ends with .jpg, .jpeg. this works fine on the jubmit button using onclick="myHandler(this)"
3
24530
by: jeff | last post by:
Hello, I have a form that submits it's values to a pop-up window. I've simplied the code: <form name="formname" action="action.php" target="windowName" method="post" onsubmit="window.open('', this.target, 'dialog,modal,scrollbars=yes,resizable=no,width=300,height=200,left=362,top=284');">
4
2724
by: Kai Grossjohann | last post by:
I have two frames. Frame "search" contains a search form specifying an onsubmit action like so: <form ... onsubmit="foo();"> ... </form> The other frame contains a <img ... onclick="perform_search();"> where the perform_search function is defined as follows:
3
12136
by: n3mtkj3mzsir0cy | last post by:
I have created web pages that do client-side form validation using the onclick directive. E.g., <form action=other_page.cgi method=post> Enter your age: <input name=age> <input type="submit" value="" onclick="return validate_form()"> </form> where validate_form() returns true or false depending on whether the user entered a valid age.
2
8558
by: JHB | last post by:
Hi, How can I do a location.replace when I use a form, like when I use a href? This works. <a href="Ny HTML-side20.htm"; method="post" id="frm" name="BrugerHovedSide" onsubmit="location.replace(this.href);" > <input class="ok" type="submit" value="Opfrisk data" id=submit1 name=submit1> </a>
10
6602
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> This works fine, the form details are collected by RegDetails.asp I am attempting to include javascript server side validation for the
3
10688
by: eric.goforth | last post by:
Hello, I'm getting a form undefined when I try to validate a date field. I've created a much simpler version of my web page that reproduces the issue, can anyone tell me why I can't access the Text field on my form like I'm trying to do? <html> <head>
1
10800
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I have defined the relavant function method in the code for details) The issue is that when Icall targetForm._submit() method from the newSubmit() function the page I get an 'Object doesn't support this property or method' error I am using IE...
5
2987
by: programmerboy | last post by:
I never had this kind of issue before and it is completely surprising. I have a usercontrol where I need 2 forms to make 1 form. When I have only 1 form it submits the page to itself. I have spent hours on this and couldn't find the solutions, thats why I have to come with a hack. I have two forms, I made the first form invisible and let the second form visible.This form is for google custom search engine. I also tried with other test forms, but...
0
8357
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8277
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8803
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7298
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.