The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I am looking into using this very cool script, but I have 1 small issue... I need to use any other tag other than the value. I am using the value for PHP and need to have a 2 char value here... but I have a full value going to PHP. Would it be possible for me to have the script read the id ?

If you have any suggestions on how I can make this work, that would be fantastic!

I want to modify the javascript so that I can keep my full name values but still let the script work as intended. That is why I was thinking may I could have javascript pull from the id tag(or name or anything else) like this, instead of the value tag.

This works great when I am only using the 2 digit abbreviation. I just want to be able to call that 2 digit abbreviation from a different tag then the value. If I can change the javascript to look on another tag.. it would be perfect..

I think I see what you're trying to do. It appears as if you have a hard-coded string that you're parsing through to determine the 2-digit state code for a given zip code. From there, the script 'selects' the correct state from the select box.

At the same time, you're trying to get the full state name into your PHP script - but you want to use javascript to accomplish it.

I would argue that you should use a server-side script - but I digress. One way to achieve your goal is to have a 'state' javascript object, which you could then use to populate a hidden form field:

Code:

var states = {
'MI':'Michigan',
'CA':'California',
'TX':'Texas'
};

In the 'setState' function you're currently using to set the select box to the proper option, you can use the states object to fill in the hidden field:

OK well I put the code together and the rest of the code seems allergic to it... If I have the var list or the code you added in the existing code.. it doesn't work. I want the full name to go to PHP, but the 2 digit name= is what javascript is using to assign the value. Should the js object/var list be in the other script in a particular order? Maybe I'm just not putting it together correctly.