• (cs)

    A selecter, huh?  So what's the selectest!

  • AndrewVos (unregistered)

    Dare I say "Javascript has the best WTF's" ?

  • (cs)

    Rofl, so if I'm reading this right, if he has 10, 210, 310 and 410 checked, and he unchecks 10, he ends up with 234 checked?  Good thing the ids are so high!

    What does the g in the eval line do?

  • (cs) in reply to rmr
    rmr:
    Rofl, so if I'm reading this right, if he has 10, 210, 310 and 410 checked, and he unchecks 10, he ends up with 234 checked?  Good thing the ids are so high!

    What does the g in the eval line do?


    g = global replace.  otherwise, only the first "10," would be replaced.
  • (cs)
    Alex Papadimoulis:

    The root folder housed over 400 of files, most belonging to completely different modules. Actually, there was one subfolder: it contained all the code and pages for the previous programmer's World of Warcraft clan website.



    I was originally going to make a joke about the javascript as an effort to make sure that the checked checkboxes were, like, really checked, so they didn't have a situation like the 2000 Florida vote with the hanging chads and whatnot.

    Then I re-read the bit about the WoW site and though, aw, hell, that's funnier than anything I could come up with anyway.
  • (cs)

    I guess he is unfamiliar with $_POST in PHP?

  • (cs)

    Is it safe to remove my welding goggles yet?

  • (cs) in reply to kipthegreat
    kipthegreat:
    rmr:
    Rofl, so if I'm reading this right, if he has 10, 210, 310 and 410 checked, and he unchecks 10, he ends up with 234 checked?  Good thing the ids are so high!
    What does the g in the eval line do?

    g = global replace.  otherwise, only the first "10," would be replaced.

    Yeah, this is awesome!  For fun, paste this code on your machine at work, add some checkboxes where the ids are substrings of the other ids, and change the hidden input to text so you can see it as it messes up the list of ids.

    And all this for something the browser does for you when it posts the form, had the developer been 1337 enough to give all the checkboxes the same name, with each value being the id.
  • (cs) in reply to CodeRage

    CodeRage:
    kipthegreat:
    rmr:
    Rofl, so if I'm reading this right, if he has 10, 210, 310 and 410 checked, and he unchecks 10, he ends up with 234 checked?  Good thing the ids are so high!
    What does the g in the eval line do?

    g = global replace.  otherwise, only the first "10," would be replaced.

    Yeah, this is awesome!  For fun, paste this code on your machine at work, add some checkboxes where the ids are substrings of the other ids, and change the hidden input to text so you can see it as it messes up the list of ids.

    And all this for something the browser does for you when it posts the form, had the developer been 1337 enough to give all the checkboxes the same name, with each value being the id.

    Yes, but then he wouldn't be able to handle "input" from mutliple pages in his insert.php file.  At least that's what i'm guessing he did.  Based on the prefix of fthe checkboxes, he probably had some huge switch statement in that file that knew what values were selected on what page.  It's the new duct tape...insert.php!

    Or, am I completely off here?

  • (cs)

    I did not interpret "in trouble" as getting fired.  If he did not get fired for trying to sell proprietary software on eBay...that might be a bigger WTF than his whole system.

  • (cs) in reply to kipthegreat
    kipthegreat:
    I guess he is unfamiliar with $_POST in PHP?


    Unnecessary:  assuming the point of this was to convert a POST to a GET, all he had to do was change
    <form method="POST"> to <form method="GET">


    I'm pretty sure GET is the default anyway.  I can't for the life of me figure out why the fuck he thought he needed the javascript.
  • rocksanddirt (unregistered) in reply to AndrewVos

    As javascript in itself was designed with good intentions, there are many facets about the language and the varying browser capabilities that can eventually drive your code into WTFland for the next developer...

  • Gnictigezoink (unregistered)

    Holy crap.

    Err. Unholy Crap.

    'Nother instance of "TTWTASO" design pattern (trash the whole thing and start over)

  • wyz (unregistered)

    The story around it is differenct, or this could be jscript from the place I at now as an on-site contractor!

    This job was presumably modifying about 8 web pages. But it turned out the pages had server-side jscript rendering client-side jscript with this kind of garbage code, plus putting values in and out of XML strings by someone not knowing how to use XML. That just my rant on the web pages! 

    In fact, some samples were submitted to WTF, but Alex only had sympathy for me. Don't recall if it was duplicate stuff or wasn't humorous enough to use. But it has kept some of my sanity reading WTF and seeing I'm not the only one dealing with bad coding and applications.

    (Someone had to ask real nice to get me to come here and rescue a project that was sinking. The first guy placed here couldn't figure out what to do.)

     

  • (cs)

    Oh yes, forget the whole $_REQUEST.....very nice. I've always wanted to create the new and improved version of that. Lol...
    It's almost as bad as the new link tag seen elsewhere on this site last week...
    <a onclick="location='http://www.aximilation.com'; return false;" href="#">The <em>new</em> link!</a>
    (I'm making a t-shirt!)

  • (cs) in reply to Digitalbath
    Digitalbath:

    Yes, but then he wouldn't be able to handle "input" from mutliple pages in his insert.php file.  At least that's what i'm guessing he did.  Based on the prefix of fthe checkboxes, he probably had some huge switch statement in that file that knew what values were selected on what page.  It's the new duct tape...insert.php!

    Or, am I completely off here?



    This is what happens when someone hears the term 'MVC' in passing and then reads a random blog post. Because nothing controls like a single file with 20,000 if statements.
  • Anon (unregistered)
    Alex Papadimoulis:

    <script type="text/javascript"> <!--

    function onCheck(id)
    {
      checkedValues = document.selecter.checkedValues;
      checkedBox = document.selecter["check_"+id];
     
      if (!checkedBox.checked)
        checkedValues.value =
               eval("checkedValues.value.replace(/" +id + ',' + "/g,'')");
      else
        <FONT size=4>checkedValues.value+=(id+',');
    </FONT>}
         
    function submit()
    {
      document.location.href = 'insert.php?chosen=' +
         document.selecter.checkedValues.value;
      return false;
    }


    //--
    ></script>

    <form id="selecter" name="selecter">
      <input type="hidden" id="checkedValues" name="checkedValues" />
      <input class="button" type="button" value="Submit" onclick="submit()" />

      <input id="check_4273844" onclick="onCheck('4273844')" type="checkbox"
             name="check_4273844" <FONT size=4>value="ON"</FONT>
    />
      ...
      <input id="check_4273843" onclick="onCheck('4273843')" type="checkbox"
             name="check_4273843" <FONT size=4>value="ON"</FONT>
    />
      ...
      <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <FONT size=4>value="ON"</FONT>
    />
      ...
    </form>

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

  • (cs) in reply to Aximilation
    Aximilation:
    Oh yes, forget the whole $_REQUEST.....very nice. I've always wanted to create the new and improved version of that. Lol...
    It's almost as bad as the new link tag seen elsewhere on this site last week...
    <a onclick="location='http://www.aximilation.com'; return false;" href="#">The <em>new</em> link!</a>
    (I'm making a t-shirt!)


    Resistance is futile.
  • foo (unregistered)

    It's so beautiful! I'm crying... no wait... that's blood... FROM MY EYES!

  • maht (unregistered)

    the guy almost invented Ajax

  • Anon (unregistered) in reply to Anon
    Anonymous:

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

    Wait, I was wrong.  That doesn't say "checked" it says "on".  This was so stupid I mentally filled in what he should have been doing instead of what he actually did.

     

    Wow, that's a lot of work to be so wrong.

  • Tomer Chachamu (unregistered) in reply to Anon

    Actually, 'value="ON"' does not mean the box is checked. It just means that if it is checked, the value to send to the server is "ON".

    Considering that that value presumbly isn't used (since checkedValues.value holds the list of checked checkboxes) you have to wonder why it's there. Just another copy-paste job, I suppose...

  • (cs) in reply to Anon
    Anonymous:
    Anonymous:

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

    Wait, I was wrong.  That doesn't say "checked" it says "on".  This was so stupid I mentally filled in what he should have been doing instead of what he actually did.

    Wow, that's a lot of work to be so wrong.

    Web-neophyte here - I thought check boxes could only be true/false, or possibly [un]checked. "On" ???

  • ole gustie (unregistered) in reply to Anon
    Anonymous:
    Alex Papadimoulis:

    <script type="text/javascript"> <!--

    function onCheck(id)
    {
      checkedValues = document.selecter.checkedValues;
      checkedBox = document.selecter["check_"+id];
     
      if (!checkedBox.checked)
        checkedValues.value =
               eval("checkedValues.value.replace(/" +id + ',' + "/g,'')");
      else
        <FONT size=4>checkedValues.value+=(id+',');
    </FONT>}
         
    function submit()
    {
      document.location.href = 'insert.php?chosen=' +
         document.selecter.checkedValues.value;
      return false;
    }


    //--
    ></script>

    <form id="selecter" name="selecter">
      <input type="hidden" id="checkedValues" name="checkedValues" />
      <input class="button" type="button" value="Submit" onclick="submit()" />

      <input id="check_4273844" onclick="onCheck('4273844')" type="checkbox"
             name="check_4273844" <FONT size=4>value="ON"</FONT>
    />
      ...
      <input id="check_4273843" onclick="onCheck('4273843')" type="checkbox"
             name="check_4273843" <FONT size=4>value="ON"</FONT>
    />
      ...
      <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <FONT size=4>value="ON"</FONT>
    />
      ...
    </form>

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

     

    <FONT face=Arial size=2>Huh?  value="on" doesn't autocheck a box on the page load.  I think you are thinking of</FONT>

     <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <FONT size=4>checked</FONT>
    />

    <FONT face=Arial size=2>Or am I missing something (trust me, its happened before)?</FONT>

  • ole gustie (unregistered) in reply to snoofle
    snoofle:
    Anonymous:
    Anonymous:

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

    Wait, I was wrong.  That doesn't say "checked" it says "on".  This was so stupid I mentally filled in what he should have been doing instead of what he actually did.

    Wow, that's a lot of work to be so wrong.

    Web-neophyte here - I thought check boxes could only be true/false, or possibly [un]checked. "On" ???

    Check boxes pass whatever is in the "value" attribute to the form action page when they are checked.  If they are not checked, they pass nothing.  If more than one checkboxes have the same name,  all that are checked are passed in a single variable as a comma seperated list.  Basically, the guy/gal wrote a bunch of crap code to do what standard html forms already do.

  • (cs)

    It burns.

    It burns. So. Much.

    Please. Someone make it stop!

  • (cs) in reply to ole gustie
    ole gustie:
    snoofle:
    Anonymous:
    Anonymous:

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

    Wait, I was wrong.  That doesn't say "checked" it says "on".  This was so stupid I mentally filled in what he should have been doing instead of what he actually did.

    Wow, that's a lot of work to be so wrong.

    Web-neophyte here - I thought check boxes could only be true/false, or possibly [un]checked. "On" ???

    Check boxes pass whatever is in the "value" attribute to the form action page when they are checked.  If they are not checked, they pass nothing.  If more than one checkboxes have the same name,  all that are checked are passed in a single variable as a comma seperated list.  Basically, the guy/gal wrote a bunch of crap code to do what standard html forms already do.

    Thanks - I know just enough about all-things-web to realize how little I know about all-things-web (I tend to stay on the server-side of things - where I know what I'm doing).

  • (cs) in reply to ole gustie
    Anonymous:
    Check boxes pass whatever is in the "value" attribute to the form action page when they are checked.  If they are not checked, they pass nothing.  If more than one checkboxes have the same name,  all that are checked are passed in a single variable as a comma seperated list.  Basically, the guy/gal wrote a bunch of crap code to do what standard html forms already do.


    I knew this didn't sound right, so I tried it. What I got in the URL for a GET request looked like this:
    key=test&key=test2

    Now, your language/CGI parser library may change this into something nicer like a comma separated list for you, but the data is actually sent as multiple key=value pairs, only using the same keys.

  • (cs) in reply to ole gustie
    Anonymous:
    Anonymous:
    Alex Papadimoulis:

    <script type="text/javascript"> <!--

    function onCheck(id)
    {
      checkedValues = document.selecter.checkedValues;
      checkedBox = document.selecter["check_"+id];
     
      if (!checkedBox.checked)
        checkedValues.value =
               eval("checkedValues.value.replace(/" +id + ',' + "/g,'')");
      else
        <font size="4">checkedValues.value+=(id+',');
    </font>}
         
    function submit()
    {
      document.location.href = 'insert.php?chosen=' +
         document.selecter.checkedValues.value;
      return false;
    }


    //--
    ></script>

    <form id="selecter" name="selecter">
      <input type="hidden" id="checkedValues" name="checkedValues" />
      <input class="button" type="button" value="Submit" onclick="submit()" />

      <input id="check_4273844" onclick="onCheck('4273844')" type="checkbox"
             name="check_4273844" <font size="4">value="ON"</font>
    />
      ...
      <input id="check_4273843" onclick="onCheck('4273843')" type="checkbox"
             name="check_4273843" <font size="4">value="ON"</font>
    />
      ...
      <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <font size="4">value="ON"</font>
    />
      ...
    </form>

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

     

    <font face="Arial" size="2">Huh?  value="on" doesn't autocheck a box on the page load.  I think you are thinking of</font>

     <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <font size="4">checked</font>
    />

    <font face="Arial" size="2">Or am I missing something (trust me, its happened before)?</font>



    Sure you're not missing anything.

    WTF on WTF
  • (cs) in reply to Otto

    Thanks for the correction.  I guess you learn something new everyday.  I am mainly a client app programmer, so my experience is limited to a couple ASP and coldFusion (gross, I know) hobby sites I help my fellow geeks maintain.

    And the answer to your question is that you learn to keep commas out of the indivdual checkbox values pretty quickly.

  • (cs) in reply to Tomer Chachamu

    Actually, 'value="ON"' does not mean the box is checked. It just means that if it is checked, the value to send to the server is "ON".

    My eyes are checkered, does that mean they are on?

  • (cs)
    Alex Papadimoulis:
          
    function submit()
    {
      document.location.href = 'insert.php?chosen=' + 
         document.selecter.checkedValues.value;
      return false;
    }
    

    I'm afraid of:

          
    //insert.php
    mysql_query("INSERT INTO MyOrder (ID) VALUES ($chosen)");
    
  • (cs) in reply to qbolec

    Good god, I actually tore at my skin with my fingernails when I read this.

    [image]
  • cedric (unregistered)

    I could imagine why one would want to reconstruct the querystring and bypass the normal form submission. For instance if there is another javascript function attached to the onSubmit event and for some reason you don't want it to run when you click on that button.

    The eval on the string replace is a bit weird. It looks like a workaround for someone who don't know about the RegExp() object (you can't use variables with the // notation). But you don't really need a regular expression in the first place.

  • (cs) in reply to qbolec

    <font face="Courier New" size="2"><font face="Arial">Just to clarify from the PHP people... Is there some reason you wouldn't just use the following ... like I'd do with a Java/Servlet back-end?  Is there some reason building a comma separated string would make things easier in PHP?  I would just use the HttpServletRequest to give me an array of the "chosen" parameters...</font>

    <form id="selecter" name="selecter" action="insert.php">
      <input class="button" type="submit" value="Submit" />
      ...
      <input type="checkbox" name="chosen" value="4273844" />
      ...
      <input type="checkbox" name="chosen" value="4273843" />
      ...
      <input type="checkbox" name="chosen" value="4273842" />
      ...
    </form>

    </font>

  • UTU (unregistered)
    Anonymous:
    PHP apparently discards all but the last value unless the name ends with [], which isn't even legal HTML.


    Umm.. how so? If my memory serves me correctly, "name"-attribute of input-elements is of type CDATA, which means "a sequence of characters from the document character set"... so ending a name with [] is just about as allowed in HTML as ... well, just about anything :)
  • (cs) in reply to Volmarias
    Volmarias:
    Good god, I actually tore at my skin with my fingernails when I read this.

    [image]



    Oooh, I need to get a webcam at my desk too.

  • Kelsey (unregistered) in reply to snoofle

    Young Padewan - checkboxes have three states - true, false, and FileNotFound.
    "On" is indeed the real WTF here.

  • (cs) in reply to qbolec
    qbolec:
    Alex Papadimoulis:
          
    function submit()
    {
      document.location.href = 'insert.php?chosen=' + 
         document.selecter.checkedValues.value;
      return false;
    }
    

    I'm afraid of:

          
    //insert.php
    mysql_query("INSERT INTO MyOrder (ID) VALUES ($chosen)");
    


    Yeah, let's combine a great big web app design flaw with a PHP-specific design flaw: SQL injection annnnnd register_globals... =)
  • Licky Lindsay (unregistered) in reply to ole gustie
    ole gustie:
    I am mainly a client app programmer, so my experience is limited to a couple ASP and coldFusion (gross, I know) hobby sites I help my fellow geeks maintain.


    You would be very surprised (well, no, you wouldn't really) how many people who work with one of those languages every day, and are paid to do so, actually think that the browser sends a comma-separated list.

    captcha: whiskey
  • Licky Lindsay (unregistered) in reply to UTU
    Anonymous:
    Anonymous:
    PHP apparently discards all but the last value unless the name ends with [], which isn't even legal HTML.


    Umm.. how so? If my memory serves me correctly, "name"-attribute of input-elements is of type CDATA, which means "a sequence of characters from the document character set"... so ending a name with [] is just about as allowed in HTML as ... well, just about anything :)


    PHP isn't the only "framework" that uses that kind of thing either. Struts, for instance, uses the hell out of it.

    Captcha: error
  • Ann Coulter (unregistered) in reply to ole gustie
    Anonymous:
    Anonymous:
    Alex Papadimoulis:

    <script type="text/javascript"> <!--

    function onCheck(id)
    {
      checkedValues = document.selecter.checkedValues;
      checkedBox = document.selecter["check_"+id];
     
      if (!checkedBox.checked)
        checkedValues.value =
               eval("checkedValues.value.replace(/" +id + ',' + "/g,'')");
      else
        <font size="4">checkedValues.value+=(id+',');
    </font>}
         
    function submit()
    {
      document.location.href = 'insert.php?chosen=' +
         document.selecter.checkedValues.value;
      return false;
    }


    //--
    ></script>

    <form id="selecter" name="selecter">
      <input type="hidden" id="checkedValues" name="checkedValues" />
      <input class="button" type="button" value="Submit" onclick="submit()" />

      <input id="check_4273844" onclick="onCheck('4273844')" type="checkbox"
             name="check_4273844" <font size="4">value="ON"</font>
    />
      ...
      <input id="check_4273843" onclick="onCheck('4273843')" type="checkbox"
             name="check_4273843" <font size="4">value="ON"</font>
    />
      ...
      <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <font size="4">value="ON"</font>
    />
      ...
    </form>

    Notice the bolded parts.  When the page loads, all the boxes are checked.  If you submit without un-checking and re-checking the box you want, there is no value in the "checkedValues" field.

     

    <font face="Arial" size="2">Huh?  value="on" doesn't autocheck a box on the page load.  I think you are thinking of</font>

     <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <font size="4">checked</font>
    />

    <font face="Arial" size="2">Or am I missing something (trust me, its happened before)?</font>



    Well, if you're going to use xhtml you should make it

    <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox"
             name="check_4273842" <font size="4">checked</font>
    ="<font size="4">checked</font>"/>
  • WHO WANTS TO KNOW? (unregistered)

    Actually, PHP even has a design flaw that makes this CHILDS PLAY!  Then again, the new PROPER way isn't much harder.  PHP was built from the ground up to work with this stuff.

    Steve

  • (cs)
    Anonymous:

    Yes, there is a reason. See http://fi2.php.net/manual/en/faq.html.php#faq.html.arrays for explanation. However, if your example were like 'name="chosen[]"', there would be no problem; we'd have array $_GET["chosen"] to use :)


    Hard to believe. How can a programming language especially made for web programming require such client-visible workarounds to accomplish such basic tasks? Even Oracle's Web toolkit (web programming in PL/SQL, introduced around '99) does it better.
  • (cs) in reply to Licky Lindsay
    Anonymous:

    PHP isn't the only "framework" that uses that kind of thing either. Struts, for instance, uses the hell out of it.

    Maybe, but struts has a higher level of abstraction.
  • Rich (unregistered) in reply to UTU

    PHP will only accept arrays of inputs if the input is named with a [] suffix. This is a pet peeve of mine, I feel that a proper server side web scripting language should be able to handle whatever form data is sent at it sanely.

    If I remember ASP correctly (it's been a while), if you read the input directly, you get a comma separated list but you can also read the input as an array [Don't remember how but it's fairly simple]. I think the comma separated list is an awful holdover from htx/idc of the original IIS (Makes me feel queasy just thinking about it).

    Rich

  • (cs) in reply to ammoQ
    ammoQ:


    Hard to believe. How can a programming language especially made for web programming require such client-visible workarounds to accomplish such basic tasks? Even Oracle's Web toolkit (web programming in PL/SQL, introduced around '99) does it better.


    It's not a work-around, it's just how things are done. PHP isn't an amazingly clever language, but what's wrong with using [] to return an array? It's no more client-visible than using the same name without [] for each element.
  • Rich (unregistered) in reply to ammoQ
    ammoQ:

    Hard to believe. How can a programming language especially made for web programming require such client-visible workarounds to accomplish such basic tasks? Even Oracle's Web toolkit (web programming in PL/SQL, introduced around '99) does it better.


    Not that I want to be seen to be defending PHP particularly (I use it a fair bit but I am a sysadmin, no longer a full-time programmer) but it must be remembered that PHP originated as a very simple language to make designing simple homepages quick and relatively painless. Crap such as [] is pretty easy to understand in that context, much like the magic quotes and other braindead stuff.

    That said, it should have deprecated by now and been replaced with something saner. I did ask about it recently and was told that there were technical reasons or ot was "too difficult" to do things any other way (which I immediately rebutted of course). I took that to mean that the PHP developers had not yet had the appropriate epiphany. I am sure they will. But in the meantime, the insanity remains.

    Rich
  • (cs) in reply to savar
    savar:
    ammoQ:


    Hard to believe. How can a programming language especially made for web programming require such client-visible workarounds to accomplish such basic tasks? Even Oracle's Web toolkit (web programming in PL/SQL, introduced around '99) does it better.


    It's not a work-around, it's just how things are done. PHP isn't an amazingly clever language, but what's wrong with using [] to return an array? It's no more client-visible than using the same name without [] for each element.


    What's wrong with that? Well, it means PHP can be unable to process (perfectly legal from a HTTP point of view) input coming from another page (possibly even another server) that does not know or care about that.
    It means implementation details inevitably leak through to a tier where they should be invisible.
  • (cs)
    Anonymous:
    Anonymous:
    CodeRage:
    <font face="Courier New" size="2"><font face="Arial">Just to clarify from the PHP people... Is there some reason you wouldn't just use the following ... like I'd do with a Java/Servlet back-end?  Is there some reason building a comma separated string would make things easier in PHP?  I would just use the HttpServletRequest to give me an array of the "chosen" parameters...</font>

    <form id="selecter" name="selecter" action="insert.php">
      <input class="button" type="submit" value="Submit" />
      ...
      <input type="checkbox" name="chosen" value="4273844" />
      ...
      <input type="checkbox" name="chosen" value="4273843" />
      ...
      <input type="checkbox" name="chosen" value="4273842" />
      ...
    </form>

    </font>


    Yes, there is a reason. See http://fi2.php.net/manual/en/faq.html.php#faq.html.arrays for explanation. However, if your example were like 'name="chosen[]"', there would be no problem; we'd have array $_GET["chosen"] to use :)


    Cheers for this!  I am relitivly new to PHP programming and was trying to do somthing similar (trying to get PHP to accept an array of inputs, not the horrible javascript thing) and ran out of energy to Google it and find out. So this just saved me some time.  I have done similar things in perl and PL/SQL and both seem simpler to me but I guess it is just a quirk of the language.


    Yeeesh, I'm glad I don't use PHP.  How hard is it to parse the key/value pairs in the http post or get, and then build an array for any key that has more than one occurrence...Anyway, thanks to all for clarifying this to me.

Leave a comment on “A New Type of Formation”

Log In or post as a guest

Replying to comment #:

« Return to Article