Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript common.js problem

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #145578

    My search bar is not working correctly.

    I have it in my top bar which the id is firstnbar.

    I can not seem for work it out in my common.js file.

    <form class="navbar-search">
    <div class="input-append">
    <input name="search" type="text"  placeholder="Search Our Store" value="<?php echo $search; ?>" >
    <button type="submit" class="btn btn-inverse"><i class="icon-search icon-white"></i></button>
    </div>
    </form>
    
    $(document).ready(function() {
       /* Search */
       $('#firstnbar .navbar-search button').bind('click', function() {
          url = $('base').attr('href') + 'index.php?route=product/search';
    
          var search = $('input[name=\'search\']').attr('value');
    
          if (search) {
             url += '&search=' + encodeURIComponent(search);
          }
    
          location = url;
       });
    
       $('#firstnbar .navbar-search input[name=\'search\']').bind('keydown', function(e) {
          if (e.keyCode == 13) {
             url = $('base').attr('href') + 'index.php?route=product/search';
    
             var search = $('input[name=\'search\']').attr('value');
    
             if (search) {
                url += '&search=' + encodeURIComponent(search);
             }
    
             location = url;
          }
       });
    
Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.