lundi 29 décembre 2014

Select box automatically redirects when clicked


I made,options in select box clickable. However for the very first option I din't put any link. But just when I click on the select box it redirects to somewhere and says page not found.


But if you click on the arrow and hold for a while then the dropdown appears.Now when u click any of the option it works. But I wonder why at first it doesn't shows the dropdown and just redirect.


here's the js fiddle: http://jsfiddle.net/58cqc812/


HTML



<select id="myselect">
<option>Go To ...</option>
<option value="<?php echo $data['config']['SITE_DIR']; ?>/">Home</option>
<option value="<?php echo $data['config']['SITE_DIR']; ?>/main/page/about-us">About Us &#9662;</option>
<option value="<?php echo $data['config']['SITE_DIR']; ?>/main/page/the-centre-point-of-any-web-projects">Centre-Point of Web Projects</option>
<option><a href="#">Branches &#9662;</a>
<?php #Core::getHook('block-branches'); ?></option>
<option value="<?php echo $data['config']['SITE_DIR']; ?>/main/news">News</option>
<option value="<?php echo $data['config']['SITE_DIR']; ?>/main/event">Events</option>
<option value="<?php echo $data['config']['SITE_DIR']; ?>/contact">Contact Us</option>
</select>


JS



<script>
//$('#myselect').on('change', function() {
//location.href=$(this).data('url');
//});
document.getElementById("myselect").onclick = function(d){
window.location = this.value;
};
</script>


You can refer to the live site. You need to resize the browser to the smallest, then only this menu appears.It's meant for mobile version. http://ymm.valse.com.my/





Aucun commentaire:

Enregistrer un commentaire