Announcement

Collapse
No announcement yet.

Dropdown menus ignoring the SELECTED attribute

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dropdown menus ignoring the SELECTED attribute

    Hi folks,

    I'm working with a customized version of the Product Attributes template, and I'm getting some weird behavior with dropdown menus. My template is generating this HTML:
    Code:
    <select name="Product_Attributes[5]:value">  
     <option value="r">Rock</option> <option value="p">Paper</option> <option SELECTED value="s">Scissors</option> </select>
    (Sorry for the bad layout; there's something wrong with the forum today.) -- but on my screen, the "Scissors" element is not pre-selected. The menu always comes up with the first option selected, regardless of what the value is. I've seen this before from time to time. I assume that there's some Javascript involved, but I don't know where to find it or how to override it, other than some brute-force JS at the bottom of the page. I feel like there should be an easier way. Does anyone know how to fix this?

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    Is this Firefox or does it occur in multiple browsers. Firefox always had odd drop down select behaviours. Don't know if they ever fixed them. If so, just google it for a couple of suggestions such as using 'autofill=off'. otherswise, it might be faster just to put in jQuery controls to do the preselecteding as that would override pretty much everything.
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      As a matter of fact, Yes, I'm using Firefox. And I figured out later last night that that was the cause of the problem. When I reloaded the page, the menu would retain the previous state instead of resetting to match the SELECTED attribute in the HTML. If I use Shift-reload, it works as expected.

      ... Funny thing, when I was typing just now, I accidentally wrote "Firedfox." Freudian slip? :^) I like the idea of using a browser that's owned by a foundation, instead of a big corporation. But it does have its quirks.
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment


        #4
        I have what may be a similar problem. The store owner would now like to have the first item in every product size selection to include "Please choose a size". Since adding the "Please choose a size" to every product by hand isn't the answer (and it doesn't seem to show up even after adding it - perhaps due to the inventory variants). So I'm attempting to add the select option in the Product Display Product Attribute Template and have added an option right before the mvt:foreach statement
        Code:
        <option value="" selected>Please choose a size</option>
        But it's not obeying the "selected", instead its still displaying the first item in the attributes for the product

        Code:
         
         <select name="Product_Attributes[1]:value" id="" class="input-medium" data-attribute="FlightSuitSize"> <option value="" selected>Please choose a size</option>  <option value="P" data-option-price="0" data-regular-price=""> Petite </option>
        Do I need to include that data stuff to get it to be the first option that displays? I don't want to include a value (if I don't have to). You can see it here


        Leslie Kirk
        Miva Certified Developer
        Miva Merchant Specialist since 1997
        Previously of Webs Your Way
        (aka Leslie Nord leslienord)

        Email me: [email protected]
        www.lesliekirk.com

        Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

        Comment


          #5
          You may want to take a look at the attribute's options (when editing the attribute in the admin.) It's possible that one of the options is set to be the "default option", in which case, the product attribute template is typically coded to look for that and, for that option, add the "selected" attribute to the option element. You can confirm if this is the culprit by "inspect element" on the <select> or viewing the page's source and seeing if multiple option elements have the "selected" attribute.

          As noted above, some browsers will persist the previous state of form controls when you reload the page. This can be overcome by doing a "hard refresh" or just by hitting "enter" with the browser's address bar in focus.
          Justin Sims
          216digital
          Cleveland Area - Code and Design
          https://216digital.com/

          Comment


            #6
            Originally posted by 216justin View Post
            You may want to take a look at the attribute's options (when editing the attribute in the admin.) It's possible that one of the options is set to be the "default option", in which case, the product attribute template is typically coded to look for that and, for that option, add the "selected" attribute to the option element. You can confirm if this is the culprit by "inspect element" on the <select> or viewing the page's source and seeing if multiple option elements have the "selected" attribute.

            As noted above, some browsers will persist the previous state of form controls when you reload the page. This can be overcome by doing a "hard refresh" or just by hitting "enter" with the browser's address bar in focus.
            Checking the product's attribute settings was the first place I checked. A default was not set. A hard refresh doesn't seem to help either. To complicate matters, this site uses Inventory Variants, so even though this set of attributes might have come from an Attribute Template, the Attribute Template was copied not linked, in order to create the Inventory Variants.

            Leslie Kirk
            Miva Certified Developer
            Miva Merchant Specialist since 1997
            Previously of Webs Your Way
            (aka Leslie Nord leslienord)

            Email me: [email protected]
            www.lesliekirk.com

            Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

            Comment


              #7
              In that case, the attribute machine might be the culprit. When viewing the product page in the admin, you'll want to take a look at the "Attribute Machine" section. There's a setting labeled "Initial Attribute State". That should, in this case, be set to "Preload - Drop-Down Lists Contain Select One"
              Justin Sims
              216digital
              Cleveland Area - Code and Design
              https://216digital.com/

              Comment


                #8
                Originally posted by 216justin View Post
                In that case, the attribute machine might be the culprit. When viewing the product page in the admin, you'll want to take a look at the "Attribute Machine" section. There's a setting labeled "Initial Attribute State". That should, in this case, be set to "Preload - Drop-Down Lists Contain Select One"
                That was it! Thank you, Justin. I need to pull out my 216 t-shirt and wear it in honor of your assistance
                Leslie Kirk
                Miva Certified Developer
                Miva Merchant Specialist since 1997
                Previously of Webs Your Way
                (aka Leslie Nord leslienord)

                Email me: [email protected]
                www.lesliekirk.com

                Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                Comment


                  #9
                  I have one small issue since change the setting, when you land on any page with a drop down, it shows "SOLD OUT" until a selection is made. I have concerns that this might scare customers off. Suggestions?
                  Leslie Kirk
                  Miva Certified Developer
                  Miva Merchant Specialist since 1997
                  Previously of Webs Your Way
                  (aka Leslie Nord leslienord)

                  Email me: [email protected]
                  www.lesliekirk.com

                  Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                  Comment


                    #10
                    As I fear, the SOLD OUT is causing even more confusion with the customers and I need to remove the tweak until I can come up with a way to get the ADD TO CART button to NOT display SOLD OUT unless the inventory is out for that inventory variant.

                    Leslie Kirk
                    Miva Certified Developer
                    Miva Merchant Specialist since 1997
                    Previously of Webs Your Way
                    (aka Leslie Nord leslienord)

                    Email me: [email protected]
                    www.lesliekirk.com

                    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                    Comment


                      #11
                      lesliekirk I have a similar issue I think - did you ever figure this out?
                      Last edited by afiumano; 12-06-19, 07:27 AM.

                      Comment


                        #12
                        With the 'Sold Out' text? Or drop-down selections.
                        Bruce Golub
                        Phosphor Media - "Your Success is our Business"

                        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                        phosphormedia.com

                        Comment


                          #13
                          Same issue I had posted on in the other thread - making the dropdowns work properly when you have some products using Select one and others that don't. I thought the issue might be similar and that Leslie might have some insight.

                          Other Thread Link: https://www.miva.com/forums/forum/on...ate-select-one

                          Comment


                            #14
                            yea, when posting same questions in multiple places probably better to stick with the original thread and REFERENCE Other threads in that one so us poor folk don't get confused.
                            Bruce Golub
                            Phosphor Media - "Your Success is our Business"

                            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                            phosphormedia.com

                            Comment


                              #15
                              Originally posted by afiumano View Post
                              lesliekirk I have a similar issue I think - did you ever figure this out?
                              Yes and no. It seems to need a combination of coding changes and javascript tweaking. The SOLD OUT at the inventory variant level is, well not very nice. Let me find the coding that was finally cobbled together and post it.
                              Leslie Kirk
                              Miva Certified Developer
                              Miva Merchant Specialist since 1997
                              Previously of Webs Your Way
                              (aka Leslie Nord leslienord)

                              Email me: [email protected]
                              www.lesliekirk.com

                              Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                              Comment

                              Working...
                              X