473,378 Members | 1,498 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,378 software developers and data experts.

New javascripter with a function/cookie problem!

Here is the function

Expand|Select|Wrap|Line Numbers
  1. function setCookie()
  2. {
  3. cookieName = "dataCookie";
  4. var YouEntered
  5.  
  6. if(document.cookie != document.cookie)
  7. {index = document.cookie.indexOf(cookieName);}
  8. else
  9. {index = -1;}
  10.  
  11. if (index == -1)
  12. {
  13. YouEntered=document.getElementById("userName").value;
  14. document.cookie=cookie_name+"="+YouEntered+"; expires=Monday,04-Apr-2020 05:00:00 GMT";
  15. }
  16. }
  17.  
Here is the code in the default.htm
[HTML]<p>
<INPUT type="button" NAME="memberLoginButton" VALUE="Member Login" Id="submitButton"
onclick="return validate(); setCookie()">
</p[/HTML]
Nov 14 '06 #1
1 1038
acoder
16,027 Expert Mod 8TB
The problem here is the "return validate()" which won't allow the setCookie() function to execute. To solve the problem, put the setCookie function call within validate() or call it with an if condition, i.e. if (validate()) setCookie().
May 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
4
by: Yvan J. Gagnon | last post by:
I am encountering a strange problem in Netscape 7 with a CFM file I am trying to troubleshoot (the page is working fine in NS Communicator and IE). Below is a sample of the problematic line of...
2
by: Shadab | last post by:
Problem: I want to store data from a form into a cookie but the cookie size is limited to 5kb. Eventually if the saved data crosses the limit 5 it does not get saved anymore. Is there any...
7
by: Christoph Pieper | last post by:
Hi, we've the following problem : We have an asp-application which sets the cookie on first login. The cookie will never be touched during user access. The user can work the whole day, but...
2
by: shree | last post by:
Hi all, I'm trying to call javascript function via onLoad but running into a problem. I would appreciate any help and suggestion. My application is as follows. When a page loads, I want to check...
14
by: Jason Shohet | last post by:
I want a function to pause, then resume in 30 seconds. I know it sounds wierd... I have a situation that I need to write a cookie, but the user does not have rights to drive at the time the asp.net...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
2
by: printline | last post by:
Hi all I have a problem with a form script. The form script should do the following: When a user selects a value from a drop down list and hits the "next" button it should take him to a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.