Java Script

SpaceshipSpaceship
Watch

mensandwomensfo

Established Member
Impact
0
How to make sure that the cookie before the split is not null value?


function StateSuggestions() {
var oldCookie=readCookie('search');
var oldCookieArray = new Array();
*oldCookieArray = oldCookie.split(',');*
this.states = oldCookieArray;
};
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
this should work..

Code:
function StateSuggestions() {
var oldCookie=readCookie('search');
if (oldCookie != '') {  
  var oldCookieArray = new Array();
  *oldCookieArray = oldCookie.split(',');*
  this.states = oldCookieArray;
} else {
document.write("Empty!");
}
};
 
0
•••
thanks

and exactly what does it do?
 
0
•••
hey,.
quick reply there,

what it does, if its not empty it will continue and if it is empty it will say 'empty!' w/o the quotes.

steve
 
0
•••
HTML:
function StateSuggestions()
{
	var oldCookie = readCookie('search');
	var oldCookieArray = new Array();

	if (oldCookie != '' && oldCookie.substr(0, oldCookie.indexOf(",")) != '')
	{
		oldCookieArray = oldCookie.split(',');
		this.states = oldCookieArray;
	}
	else
	{
		this.states = new Array();
	}
};

little rusty w/js, and untested, but should do what you're looking for.

I could also be overthinking what you meant, and localhost's could be what you're looking for. :p
 
0
•••
hey for some reason i'm still getting an error on the page in this line

oldCookieArray = oldCookie.split(',');

the error that i'm getting is

'null' is null or not an object
 
0
•••
whos script are you using, mine or v2's ?
 
0
•••
i tried both had the same error on the same line
 
0
•••
ok..hmm.. that is very veird.. will have a look later im sorry.
 
0
•••
tried secondversions and there is no error for me.
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back