does anyone happen to have a dropdown list for an html form that has all 50 states' abbreviations? it would be really nice if i could cheat and didn't have to write the whole thing out myself.
thanks.
| SitePoint Sponsor |

does anyone happen to have a dropdown list for an html form that has all 50 states' abbreviations? it would be really nice if i could cheat and didn't have to write the whole thing out myself.
thanks.





Here is a php array of them it helps
$statelist = array("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "ON", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"
);
Please don't PM me with questions.
Use the forums, that is what they are here for.

well, at least now i have them all listed. if i do have to write it out i won't forget any.
thanks!

If you want a drop down menu containing all of those states, try:
Code:<select name="state"> <? $statelist = array("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "ON", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"); foreach($statelist as $state) { printf('<option value="%s">%s</option>',$state,$state); } ?> </select>



I have never been able to see the point of printf for this kind of thing....sure it is technically correct but the following would work functionally exactly the same:
<select name="state">
<?
$statelist = array("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "ON", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY");
foreach($statelist as $state)
{
echo "<option value='$state'>$state</option>";
}
?>
</select>
To me that makes alot more sense and it is alot less confusing.
Just my $6.78!..as we all know i am over opinionated
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!





Anyone mind if I swipe that array code?



Oooops i have opened up a can of worms havent i....i bet freddy is getting a message from one of his secretaries..."That evil onion fellar is debating something trivial"
I am going to time how long it takes him to reply...
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!





I was out getting coffee or I would have responded sooner.
The fact of the matter is that it really doesn't matter which way you do it unless your site is getting more traffic than amazon I doubt you would see a difference. Technically speaking it is probably faster to use echo but I can't stand escaping quotes and concatenating in vars I prefer to use printf. To me its just plain cleaner I always know my vars will be at the end of the line and I can see them easier. But to each his own! Chris feel free to use the array it isn't anything special I actually used php to get from another site and write to to text file in the form you see here.
Please don't PM me with questions.
Use the forums, that is what they are here for.





Oh yeah one more thing, using single quotes in html is just plain poor-coding ie. <option value=''>
Just my $6.79
Please don't PM me with questions.
Use the forums, that is what they are here for.



Darn another double posting by me....accident
<Edited by mad-onion on 01-16-2001 at 07:38 PM>
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!



HEHE...your a classic freddy...
Using ' in you HTML...yeah it is but, for this example you dont even need to enclose the string...
As for the printf...yeah each to his own...i do use it sometimes if there is like a huge line of stuff and it would be really confusing.
Echo is still me choice
and if we needed " could be done like
echo "<option value=\"$state\">$state</option>";
or
echo '<option value="'.$state.'">$state</option>';
Now the second example there is ugly code...
**I need a coffee machine on my desk, then i would never have to get off my fat butt**
And thats my <? echo $freddypostprice++;?>
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!





Yeah that would be sweet to have a coffee machine at my desk but I would be too lazy to clean it. So off to the coffee shop to spend 1.75 of my hard earned money on coffee! BTW onion are you givin me bad karma or what after this post my karma went down by 8 points! And I always give you karma when you make me laugh!
Please don't PM me with questions.
Use the forums, that is what they are here for.

mad-onion, you mean ++$freddypostprice?
And thats my <?=++$madonionpostprice?>





There ya go robp you had to go and open another can of worms.
Technically robp is correct since you would want to increment my price before echoing it so you would be one higher!
Please don't PM me with questions.
Use the forums, that is what they are here for.



rob, o yeah i overlooked that...lol
freddy, karma...i dont have anything to do with karma...which is probably why mine is so low...i dont even know how it works...is it possible to subconsciously lower someones karma?
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!



Oh and on the 1.75 of my hard earned cash...i wonder if Bill Gates is like that
Bill Gates's Son "dad can i have $5 to go get something from the shop"
Bill Gates "You are asking for $5 of my hard earned cash..."
Bill Gates's Son "Yes"
Bill Gates's "Do you realise how long it took me to earn that $5"
Bill Gates's Son "about 1/1000 of a second dad"
Bill Gates's "<red faced> Still!!!!"
Is there anyone here that has met bill gates? I know my uncle has...i wonder what he is like in person!.
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!





I bet he is a full on nerd! If I could have just one penny out of his hourly pay I would be so stoked.
Please don't PM me with questions.
Use the forums, that is what they are here for.





You're a PHP God Freddy - isn't that enough? :P People like me have to slave away knowing HALF of the major languages, never able to fully learn one!





Chris can you please tell that to my boss - maybe he will bump me up form minimum wage. Where are all the good PHP jobs?
Please don't PM me with questions.
Use the forums, that is what they are here for.



This site is an interestng Bill Gates wealth site http://web.quuxuum.org/~evan/bgnw.html ... very interesting.
Yeah freddy you and kevin are god...atleast when it comes to PHP
Some ?'s..
Do you do any other languages?
How old are you? (dont answer if you dont want im just interested to know if you are a kid or adult, im only 15, commish is 16 if memory serves me correctly)
Back to the coding now...
SiteOptions >> Services :: Products :: Contact
Developers of PHP, C++, Visual Basic, MySQL, and more!





Wow you guys are young! I wish I knew as much about programming as you guys do when I was your age. I am 27 I know some perl and can get buy in ASP and ColdFusion when I have to. I am in the middle of learning java servlets and JSP right now. When I was 15 I was chasing chicks and surfing everyday after school. I have only been doing the PHP for less than an a year.
Please don't PM me with questions.
Use the forums, that is what they are here for.





I don't think PHP existed then.
Yes mad, I'm 16. I'll be 17 in August - so I'm about halfway there.
Maybe I know more than your average 16 year old, but there are thousands of kids younger than me who know twice what I do. I'm struggling to become more advanced in PHP while getting a handle on ASP and JavaScript.
Overall I just want to learn what will get me a job, and I think ASP will do that.





Yeah alot of people want ASP but php is on the rise I think same with java servlets and JSP, so I am learning them out of necessity; but I really love PHP.
Please don't PM me with questions.
Use the forums, that is what they are here for.





Yeah, I would like to learn JSP/Java. I've got a book on Java but am simply not ready for it right now.
The goal right now is to learn as much about ASP as possible, learn a little more about the built in functions of PHP (slow, but steady), and get a solid grasp on JavaScript.
Once I have a handle on JS/ASP, I think JSP and Java will be a lot easier to tackle.
Oh yeah, and I want to learn about WAP/WML/WMLScript sometime soon.
If anyone has any real-world, first-hand advice on what I ought to learn to maximixe my value as a programmer, please say so!
Oh yeah: where'd you learn PHP, Freddy?





Luckily last year I got a job where they wanted me to learn it so I just dove in head first and started learning, I made my wife a php application to manage workout routines and it just went from there, I really like the object-oriented side of PHP with classes and methods and such it made java alot more familiar. wml is pretty easy I have been doing a few things in it. Find a WAP emulator on the net and check out http://www.snowbird.com I did some work on the wml pages, check it out! I really find it fun to program and that is what keeps me motivated, if I can give you any advice find something that you love doing and eventually the money will come.
Please don't PM me with questions.
Use the forums, that is what they are here for.
Bookmarks