php中的URL更改问题

1. I have a website , and at the top of the page, there is a dropdown list to let the users specify either English and Spanish as a language.

This works fine if the language is the first selection made on the webpage, and the URL changes to mywebsite.es/index.php?lang=es if Spanish..as it should.

However, if I perform a search further down the page using either free text entry, or by any of the other dropdown boxes, then the language part of the URL is not recognized.

So, instead of a search result ending up as

mywebsite.es/index.php?lang=es/search.php?location=&type1=&price1=&condition=&category=&q=shoes I get mywebsite.es/search.php?location=&type1=&price1=&condition=&category=&q=shoes

Here are snippets of the script I have at the moment:

<script type="text/javascript">
function go(){
location=document.lan.langu.
options[document.lan.langu.selectedIndex].value
}
</script>
<form name="lan">
<select name="langu" size="1" onChange="go()">
<option><?php print translate("Language"); ?></option>
<option value="">English</option>
<option value="/index.php?lang=es">Español</option>
</select>
</form>
<form name='search' action='<?php print $config_baseHREF ?>search.php'>

(the search.php files calls up the rest of the URL after the language).

2. Also, if the language is changed half way through a session, is there a way to change the language of the page, so that the existing content on the webpage remains, and does not go back to the home page.

Thanks

well, I did not understand your first question completely.

You should save the language in the session and in the URL. If there is a session, then use its lang param. If not, use the URL param. Having the lang in the URL is important to copy URLs. But when you script recognizes a lang param in the URL it should first write this param to the session.

You need to call a PHP function via Ajax in the onChange function. This PHP function changes the Session language. Then the URL is reloaded. Just exchange the lang param.

As I wrote before, the URL param is ignored when there is a session entry.

Hope this helps.

you set the function of javascript on change of the dropdown box

      function gotoUrl()
                 {
                    var language = document.getElementById('dropDown').value;
                    window.location="mywebsite.es/index.php?lang="+language;
               }