0

we have multi store view site with countires : India, USA, France

on top of the site we can see those 3 countries, once we click on dropdown-button here

enter image description here

what we need is instead of clicking on dropdown button, it should work with "mouse-over"

app/design/frontend/base/default/template/page/switch/languages.phtml

<?php if(count($this->getStores())>1): ?>
<div class="form-language">
    <label for="select-language"><?php echo $this->__('Your Language:') ?></label>
    <select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
    <?php foreach ($this->getStores() as $_lang): ?>
        <?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
        <option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->escapeHtml($_lang->getName()) ?></option>
    <?php endforeach; ?>
    </select>
</div>
<?php endif; ?>

I tried below 2 kind of codes, but it didt worked for me.

code 1:

$("#select-language").mouseover(window.location.href=this.value{
    $( "#select-language" ).trigger( "click" );
});

code 2

<option onmouseover="window.location.href=this.value" 
value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->escapeHtml($_lang->getName()) ?></option>
1
  • 4
    I'm voting to close this question as off-topic because this is a JavaScript only question and it's not related to Magento. Commented May 3, 2016 at 13:07

1 Answer 1

1

Use this jQuery code:

jQuery(document).ready(function () {
  jQuery('select#select-language').hover(function () {
    jQuery(this).attr('size', jQuery('option').length);
  }, function () {
    jQuery(this).attr('size', 1);
  });
});

Add this Style to this select-box

select#select-language {
    position: absolute;
    top: 3px;
    z-index: 2;
}

There's also another good solution. You should convert <select><option>... to <ul><li>... list, and apply jQuery scipt as shown here in my answer : Display the drop down values when mouse-over on text instead of textfield

4
  • what i need to replace in place of function ? Commented May 3, 2016 at 13:08
  • check updated answer Commented May 3, 2016 at 13:09
  • i updated your code, but its not working for me. i added script in same file - languages.phtml . please check link Commented May 3, 2016 at 13:11
  • edited the answer Commented May 3, 2016 at 13:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.