Link to home
Start Free TrialLog in
Avatar of aznprncritic
aznprncritic

asked on

Javascript Array

I have the following array:

var queryItems = ["phone-selector-compared=prod1233,phone-selector-compared=,phone-selector-compared=,phone-selector-type=contract,phone-selector-category=phone-selector-blackberry,phone-selector-touchscreen=1,phone-selector-camera=0.01%2C100,phone-selector-styles=phone-style-default%2C+phone-style-flip%2C+phone-style-bar%2C+phone-style-slider"];

Open in new window


I'm using the following loop:

for(var i=0; i<queryItems.length; i++) {
			var queryItem = queryItems[i].split('=');
			$('[name=' + queryItem[0] + ']').filter( '[value=' + unescape(queryItem[1]) + ']' ).attr('checked', true);
		}

Open in new window


I need to:

1) determine if 'phone-selector-compared' equals an Id ('prod1233') and if it does, what is it?

Avatar of leakim971
leakim971
Flag of Guadeloupe image

>I need to : determine if 'phone-selector-compared' equals an Id ('prod1233') and if it does, what is it?

Please confirm this is what you're trying to do with the loop
Avatar of aznprncritic
aznprncritic

ASKER

Yes, lemme clarify:

The array will always contain "phone-selector-compared", I need to determine if "phone-selector-compared" will also have a value associated with it.  Does that make sense?
var queryItem = queryItems[i].split('=');
haveAssociatedValueWithHim = (queryItem[1] != null) && (queryItem[1].length>0);
Won't that just determine if any parameters in the array have values?

Also, if phone-selector-compared does have a parameter associated with it, i need to retrieve it.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the points!