Need urgent Javascript help

Not open for further replies.
Hi lads

Im doing some work on a site which involves some javascript. Ive got the job half done already. Need help with the second half!

Basically the site has a search by area function here

So when you select an area the results show underneath.

The client wanted me to make it so when you select an area it opens a new page, specific to that area with the results showing (for seo purposes) which i have done on this test page (select bantry)

Thats all fine but the results are not showing on the new page.

Here is the form code:
<form name='restaurant_search'>
    <select id="location_dropdown" onchange="update_guesthouse_types_new(this.value)">

$myrows = mysql_query( "Select distinct meta_value from wp_postmeta where meta_key='rblocation' order by meta_value asc" );
echo mysql_numrows($myrows);
while ($row = mysql_fetch_array($myrows) ) {
   	$option_value = strtolower(current(explode(" ", $row[meta_value])));
	echo "<option value=\"$option_value\">".$row[meta_value]."</option>";

<input type='button' value='Search &raquo;' id='restaurant_search_btn' onclick="update_guesthouse_types();">



and javascript:
<script type="text/javascript">
function update_guesthouse_types_new(option){
	var base_url = "";
	location.href = base_url + option;
Any help at all with this would be very much appreciated.



New Member
Hi John,

The code all looks good from what I can see - even tested it here. Are you sure you uploaded you new code to the server, when I checked the page source the onchange in the resturant_search form is still set to
update_guesthouse_types() and not
Hi Dec

The first link I posted is the current page. That will have the old code (update_guesthouse_types())
Is that the source you are checking? If you source the second link (my hidden test page) you will see the other new code.

Hope I got that right!



New Member
Are you trying to get the results to open in a new window? The pages seem to change fine when I select a different region...
Yep I got that far myself, working fine. Thing is its not displaying the search results underneath, like the first link I posted above (the current setup).

If you want to open a new page onchange, then you could try setting the target='_blank' to the form and use POST instead of GET and use onchange='this.form.submit();'

That's an option. The second option is using AJAX to load result below the select menu. onchange='loadresults(this.value);'
I think your first option sounds good Louie. I dont want to open a new browser window though, just a new page I created. Is that how it will function?

From what I understood, you are trying to submit the form if the select menu has changed, so yes that's what the first option will do, but isn't what the current js function does?
It opens a new page, but not a separate browser window.

Will your fix solve the results showing problem though? Thanks again for the help.
Tried inserting that in the form, didnt work im afraid.

I found the javascript for the current setup (first link I posted) Problem is the new javascript is overwriting this function so its not showing the results.
 function update_guesthouse_types(){
 selObj = document.getElementById('location_dropdown');
    event_location = "Everywhere";
        selIndex = selObj.selectedIndex;
    event_location = selObj.options[selIndex].text;

mydomain=window.location.hostname;"GET", 'http://'+mydomain+'/wp-content/themes/sandbox/ajax/guesthouse_types.php?l=' + escape(event_location), true); 

  http.onreadystatechange = handleHttpResponse_restaurant_types;

  return false;
Any ideas how to make the new javascript show results also on the new page?
Not open for further replies.
Award-winning Mac antivirus and Internet security software