troubleshooting Question

Javascript to write cookie for state selector used on another page

Avatar of BearWebContent
BearWebContentFlag for Bosnia and Herzegovina asked on
JavaScriptHTML
4 Comments1 Solution314 ViewsLast Modified:
This is the information that I received, but being a novice do not know what code to add to the attached javascript file or the page where the state is selected to make it work. Can anyone help me? The idea is that the person selects a state on one page that takes them to another URL.  On that page, the user clicks another link that takes them to a page with a pre-selected state in the result based on the cookie initially selected.

Refer to: http://jason.pureconcepts.net/articles/javascript_cookie_object
- In the function setDDValue, a cookie can be set in the closure between line 117 and 124
- This cookie would have the same value as the variable 'value', passed in the function (i.e.: 'value' would be something like "Alaska")
- Since the Prototype library cannot "click" things programmatically, an event listener for a custom event needs to be created in order for it to work. Copy line 93, and paste it immediately after, and change it with a new custom even name, eg.:

Event.observe(option, 'stateSelected', (observeOption), false);

On the page that needs to be smart enough to auto select the city:

- Read the cookie stored
- If cookie exists, fire the stateSelected event for the corresponding state link, ie: $('rrtaa67').fire('stateSelected'); where rrtaa67 is the ID name of the link in custom dropdown.
- This must be after the page has done loading, so bind it to the document load event.
dropdown.js
ASKER CERTIFIED SOLUTION
Pravin Asar
Principal Systems Engineer
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros