redirect using document.location.href go to undefined>404
-
Hi Guys,
Here goes my issue: I’m executing the sql and listing the states fine in the page >> https://mywebsite.com/fairs/ and I want to select the combo and redirect to >> https://mywebsite.com/fairs/?state=CA
But wordpress is pointing to https://mywebsite.com/fairs/undefined (404 page) what am I doing wrong ?
<script type="text/javascript"> function redirect() { document.location.href = this.value; } </script> <select name="location" onchange="redirect()"> <?php foreach($states as $state) { print '<option value="'.get_bloginfo('url').'/fairs/?state='.$state->state.'">'.$state->state.'</option>'; } ?> </select>
BTW I’ve also tested those options:
1 – print ‘<option value=”/fairs/?state=’.$state->state.'”>’.$state->state.'</option>’;
2 – print ‘<option value=”/?state=’.$state->state.'”>’.$state->state.'</option>’;
3 – print ‘<option value=”?state=’.$state->state.'”>’.$state->state.'</option>’;
4 – print ‘<option value=”‘.$_SERVER[‘REQUEST_URI’].’?state=’.$state->state.'”>’.$state->state.'</option>’;
- The topic ‘redirect using document.location.href go to undefined>404’ is closed to new replies.