Loading ...
Sorry, an error occurred while loading the content.
 

Connection manager setForm returns option text when value is empty

Expand Messages
  • Michael Price
    Hi, I ve been working on something to submit a form via YUI Connection Manager. Take the following SELECT box which is part of the form:
    Message 1 of 2 , Aug 2, 2006
      Hi,
      I've been working on something to submit a form via YUI Connection
      Manager. Take the following SELECT box which is part of the form:

      <select name="customer_status_id" id="customer_status_id">
      <option value="">- ANY -</option>
      <option value="1">New customer</option>
      <option value="2">Standard</option>
      <option value="3">VIP</option>
      <option value="4">Blacklist</option>
      </select>

      Note how the value of the "- ANY -" option is set to an empty string,
      which my form parser picks up as meaning the user doesn't want to filter
      this option.

      However, there's a line in YUI connection.js setForm function which
      overrides the default browser behaviour of returning the selected value:

      this._sFormData += encodeURIComponent(oName) + '=' +
      encodeURIComponent(oElement.options[j].value ||
      oElement.options[j].text) + '&';

      This means if the option value is blank, the option text is sent
      instead. Browsers will do this is value has NOT BEEN SET (e.g.
      <option>TEXT</option>, but not if the value has been set to an empty string.

      Not a major inconvenience to check for in my PHP form parsing code but
      it is something which - I think anyway - goes against the default
      behaviour of a browser and something people may want to be aware of if
      they're getting unexpected behaviour from their requests.

      Regards,
      Michael Price
    • Thomas S. Sha
      ... string. ... I will log this request for the August update. Regards, Thomas
      Message 2 of 2 , Aug 2, 2006
        --- In ydn-javascript@yahoogroups.com, Michael Price <mike@...> wrote:

        > This means if the option value is blank, the option text is sent
        > instead. Browsers will do this is value has NOT BEEN SET (e.g.
        > <option>TEXT</option>, but not if the value has been set to an empty
        string.
        >
        > Not a major inconvenience to check for in my PHP form parsing code but
        > it is something which - I think anyway - goes against the default
        > behaviour of a browser and something people may want to be aware of if
        > they're getting unexpected behaviour from their requests.

        I will log this request for the August update.

        Regards,
        Thomas
      Your message has been successfully submitted and would be delivered to recipients shortly.