0

On a website I am working on, we have a bunch of jquery that redirects to the next level of a page based on what is chosen in a select option. The change function works perfectly fine, but google webmaster tools is not reading the code properly, and is returning a bunch of 404 errors in GWT.

var type = $('#select-type option:selected').attr('value')      ;
if (type == 'Masters' || type == 'Bachelors' || type == 'Associates')
{ 
    location.href = '/'+type+'/Degree-in-Criminal-Justice';
}

GWT returns a 404 error for /Degree-in-Criminal-Justice, and ignores the type variable, which is part of the valid url.

1 Answers1

0

How should Google Bot know he must select every option in your select to navigate further?

I propose the following: Start with HTML block containing links

Choose site:
<div id="choice">
    <a href="Masters/Degree-in-Criminal-Justice">Masters</a>
    <a href="Bachelors/Degree-in-Criminal-Justice">Bachelors</a>
    <a href="Associates/Degree-in-Criminal-Justice">Associates</a>
</div>

Then convert it with JavaScript to the clickable item:

  var choice = $("#choice")
  var choices = {}
  var select = $('<select>')
  select.append($('<option>'))
  choice.find('a').each(function(i,el){
      var text = $(el).text()
      choices[text] = el.href
      select.append($('<option>').val(text).html(text))
  })
  choice.empty()
  choice.append(select)
  select.change(function(val){
    var selectedValue = select.find('option:selected')[0].value
    if (selectedValue)
        location.href=choices[selectedValue]
  })
Danubian Sailor
  • 1
  • 38
  • 145
  • 223