2
I have a website that has 5 different languages and when choosing a language the page text changes! For this I made a function:
<script type="text/javascript">
function submitForm() {
var thelang = document.getElementById('lang').options[document.getElementById('lang').selectedIndex].value;
window.location.href = window.location.pathname +'?lang=' + thelang;
}
</script><br/>
The problem is that now I have two id
for that page, and I would like to know how to integrate in this function also the id
.
For example the url should look something like this:
localhost:8080/.../index.php?id=1&&lang=pt
, but since I couldn’t pass the id
to the variable, now the pages have stopped translating. The id
I seek via GET
if (isset($_GET['id']) && !empty($_GET['id']))
{
$id=$_GET['id'];
$id=mysqli_real_escape_string($link,$id);
$query="SELECT * FROM local where local_id='".$id."'";
$result=mysqli_query($link,$query);
while ($row=mysqli_fetch_array($result)) {
if ($row['local_id'] == 1)
{
?> //AQUI FICA O HTML <?php } ?>
Languages are chosen through a select, what is happening is that you can no longer load, I can only update the page manually, changing the URL...
This ID is where? in the DOM or server?
– Sergio
Is on the server!
– Ana
When you choose the language, the url loses the id, that’s it?
– Leite
Hello @Leite!!! In this case you can’t even choose the language, simply when I choose one nothing happens, I can only change manually
– Ana
Hello! What is the url you have before choosing a language and what it looks like after you choose it (confirms whether it changes or not)
– Leite
Before choosing the language I have so
http://localhost:8080/hoteljupiter/index.php?id=2
, then to choose the page gets all blank, but now I tried in my function sowindow.location.href = window.location.pathname +'?id=' + id +'&lang=' + thelang;
, the page now when clicking on a language is no longer empty, only nothing happens, only if you change the language manually that is in the URL– Ana
@Milk is now that I read your question better, the link after choosing the language, the id disappears yes without making that change in my function, I apologize
– Ana
Yes, that was the original problem. But with this change you made the url should be
?id=undefined&lang=pt
, that? How does the url look? It doesn’t even change the page?– Leite
The url no longer changes with this change if I choose one of the languages, just nothing happens anymore!
– Ana
Let’s go continue this discussion in chat.
– Leite