Disabled select does not pass custom field to cart

vossavantvossavant Member
in Bugs & Feature Requests edited January 2010
Hi guys,

I have a few custom fields, one of which is chosen via a dropdown. I don't think the type of input matters, but in this case it's a select menu.

When a certain combo of options is chosen, I disable the select via jQuery and choose a default value.

When the menu is disabled, the value is not passed along to the cart.

E.g.,

<select name="color"> ... </select>

When this is disabled, no "color" value is passed to the cart.

Is this just the way it is, or can I get around this? I'd like to avoid inserting hidden fields with jQuery if possible.
Comments
  • Yup, if its disabled its not going to get submitted with the form. read-only is really what you're after, but unfortunately that isnt availble to select/option objects. The rational is that its already read only anyway. If you do a search for 'read only select form' there are a few javascript solutions that you could intergrate. Not perfect, but only other way apart from hidden fields.
  • mutmut Member
    could hide the combobox instead of disabling it... just using .hide() or .show()
  • brettbrett FoxyCart Team
    If you want it disabled, perhaps just put it as a readonly text input?

    One note though: Readonly inputs can be awkward because they'll accept a double or triple click to select the text, but if the user hits backspace it'll do the browser's "back" action, which is annoying. What we do in FoxyCart fields that are disabled is to make them visually appear either disabled or not like an input at all, and also add an event to blur() if it gets the focus.

    Lots of fun, right? ;)
  • vossavantvossavant Member
    edited January 2010
    Thanks for the input fellas. I ended up using jQuery's remove() function to blow away the select, and the after() function to insert a readonly text input field. (Actually you need to first insert after and then remove.)

    Using some CSS, I prettied it up to look just like a disabled select menu.

    EDIT: Since I also needed the select menu to reappear if an option was unchecked, I instead used the hide() and show() functions. It appears that if there are two inputs with the same name, FoxyCart will grab the value of the input that appears last.
Sign In or Register to comment.