• Nick (unregistered)

    This code makes me sad as a software engineer. Hard to believe that people out there are writing shit like this.

  • Cynthia (unregistered) in reply to ounos

    Because everything is bigger in Texas!

  • Ouch! (unregistered) in reply to Cynthia
    Cynthia:
    Because everything is bigger in Texas!
    Especially the love of repetition, it seems.
  • JohnB (unregistered) in reply to Buzzard
    Buzzard:
    AussieMan:
    "It was an easy fix... but it certainly didn't solve the bigger problem."
    The problem is America has too many states. Australia is easier to maintain.

    New Zealand, moreso....

    Yup: North Island (NI), South Island (SI), West Island (WI) [Kiwis will understand]

  • ClaudeSuck.de (unregistered) in reply to eViLegion
    eViLegion:
    I particularly like the maintainability of this example.

    It's look and feel

  • (cs) in reply to Federico
    Federico:
    #!/bin/sh

    for char in W T F '!'; do if "$char" == 'W'; then echo 'W' elif "$char" == 'T'; then echo 'T' elif "$char" == 'F'; then echo 'F' elif "$char" == '!'; then echo '!' fi done

    CAPTCHA: pecus: pecus bill?

    Hey! that is my script! Where did you get it?

  • Andrew (unregistered)
    <select name="usr_province">
      <option petal:repeat="state states"
        petal:content="state/description" 
        petal:attributes="value state/abbreviation;
          selected decode: selected_state state/abbreviation
          'selected' undef" 
      />
    </select>
    
  • Nomen Nescio (unregistered) in reply to ounos
    ounos:
    <option>TN - Tennessee</option> <option >TX - Texas</option> <option>VI - U.S. Virgin Islands</option> <option>UT - Utah</option>
    That's the RTWTF. Texas' option got an extra space. WHY?

    Just be glad it doesn't have a dollar sign.

  • oheso (unregistered)

    Could we please have more comments that "Everything is bigger in Texas"? (I think we're pretty much agreed that neither short-term memory nor IQ are included in "everything" for the sake of this discussion.)

  • Soft Drink Empire (unregistered) in reply to Steve Syfuhs
    Steve Syfuhs:
    Same in Canada. Code looks similar to another app I've seen... Except we spell our variables with an 'ou' than 'o'.
    <optioun> ?
  • (cs) in reply to n00b
    n00b:
    I once wrote a php code that generated a long html form (13k lines). Basically it looked something like this:

    for (~150x) print name for (~75x) if x=y print option selected else print option

    You had a single page form, with ONE HUNDRED AND FIFTY DROP-DOWN BOXES, each containing 75 options? OUCH! I'd be bored and wander away long before reaching the bottom of the form...

    What kinds of situation would require such a monstrosity?

  • Anthony Gatlin (unregistered) in reply to @Deprecated

    It is obvious the coder just copied a snippet, didn't understand how it worked, and then just fiddled with it until it kind of did what was expected. This was most likely a government employee.

  • D (unregistered) in reply to Ville

    Why would you spoil code as funny as that.

  • gOMERpYLE (unregistered) in reply to pjt33

    [applaudes]

  • Neil (unregistered) in reply to Bri

    just because pay is based on LOC wouldnt mean you have to hand type it.

    If I WAS paid by LOC, I might do something like the above, but I would definely cut/paste or even script the writting of the whole thing

  • Chris (unregistered) in reply to dtobias

    With less repetition (in PHP):

    $states = array("AL" => "Alabama", "AK" => "Alaska"); // etc. echo "<select name='usr_state'>\n"; foreach ($states as $abbrev => $full) { echo "<option value='$abbrev'" . ($abbrev === $state ? " selected" : "") . ">$abbrev - $full</option>\n"; } echo "</select>\n";

  • jak inaczej mówimy na ruch pochodzący z seo? (unregistered)
    Comment held for moderation.
  • jak inaczej mówimy na ruch pochodzący z seo? (unregistered)
    Comment held for moderation.
  • pozycjonowanie iai shop (unregistered)
    Comment held for moderation.
  • pozycjonowanie iai shop (unregistered)
    Comment held for moderation.

Leave a comment on “The Ultimate State Selector”

Log In or post as a guest

Replying to comment #:

« Return to Article