473,411 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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.first_name.value.length != 0) {
var expdate = new Date ();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000));
SetCookie('FirstName', freeform.first_name.value, expdate);
SetCookie('LastName', freeform.last_name.value, expdate);
SetCookie('Address', freeform.address.value, expdate);
SetCookie('City', freeform.city.value, expdate);
SetCookie('State', freeform.state.value, expdate);
SetCookie('ZipCode', freeform.zipcode.value, expdate);
SetCookie('BirthMonth', freeform.birthmm.value, expdate);
SetCookie('BirthDay', freeform.birthdd.value, expdate);
SetCookie('BirthYear', freeform.birthyy.value, expdate);
SetCookie('Areacode', freeform.areacode.value, expdate);
SetCookie('Phonethree', freeform.phonethree.value, expdate);
SetCookie('Phonefour', freeform.phonefour.value, expdate);
SetCookie('SenderEmail', 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_check" value="1" >
<!--After Form my submit button:-->

<input name="submitButton" type="image" id="submitButton" src="images/
submitbutton.jpg"; />
Feb 21 '08 #1
3 1554
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.first_name.value.length != 0) {
var expdate = new Date ();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000));
SetCookie('FirstName', freeform.first_name.value, expdate);
SetCookie('SenderEmail', freeform.sender_email.value,
expdate);
return false;
} else {
alert('Please fill in all the form fields.');
return false;
}">
<input type="hidden" name="submit_check" value="1" >

Thanks.

On Feb 21, 6:00*pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
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.nlwrites:
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
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...
3
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('',...
4
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 ......
3
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"...
2
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"...
10
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"> ...
3
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...
1
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...
5
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.