PDA

View Full Version : help to solve a variable problem


Chorale
05-25-2010, 03:39 PM
Hello


I have trouble figuring why my script isn't behaving like i want.


I'm making a small page for mobile with basic information . However this page feature a googlemap and a button to switch to english/french. both with the Googlemap.


The googlemap is on a show/hide script.

The french version and the english version are both on show/hide script too. This to have only 1 language visible depending what you want to see.


I am working only the technical part right now. I've managed to make my script work, however after 1 full cycle you have to click twice on the "francais" or "english" button...


Now i know this has something to do with the state of the previous variable, however i find myself unable to reset the variable with success without making the other language part showitself....


Any help whould be welcome.


Here is the whole file, just copy and paste in a blank html page. It has no picture or anything at this point.


As much making one thing appear on a single click is easy, making that happen while hiding another is tougher, and even more to make it repeatable.


Thanks !
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">

body {
background-color:#ffffff
}

bodyfr {
background-color: #ffffff;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
font-size: 12px;
font-style: normal;
font-variant: normal;
font-weight: normal;
font-family: Verdana, Geneva, sans-serif;
}

bodyus {
background-color: #ffffff;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
font-size: 12px;
font-style: normal;
font-variant: normal;
font-weight: normal;
font-family: Verdana, Geneva, sans-serif;
}

text {
background-color: #ffffff;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
text-align: justify;
font-size: 12px;
font-style: normal;
font-variant: normal;
font-weight: normal;
font-family: Verdana, Geneva, sans-serif;
}

</style>

<script language="javascript">

var state = 'none';

function showhide(divmapfr) {

if (state == 'block') {
state = 'none';
}

else {
state = 'block';
}

if (document.all) {
eval( "document.all." + divmapfr + ".style.display = state");
}
if (document.layers) {
document.layers[divmapfr].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(divmapfr);
hza.style.display = state;
}
}

</script>

<script language="javascript">

var stateus = 'none';

function showhide2(divmapus) {

if (stateus == 'block') {
stateus = 'none';
}

else {
stateus = 'block';
}

if (document.all) {
eval( "document.all." + divmapus + ".style.display = stateus");
}
if (document.layers) {
document.layers[divmapus].display = stateus;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(divmapus);
hza.style.display = stateus;
}
}

</script>

<script language="javascript">

var statebodyfr = 'block';

function showhidebodyfr(bodyfr) {

if (statebodyfr == 'block') {
statebodyfr = 'none';
showhidebodyus('bodyus')
}

else {
statebodyfr = 'block';
showhidebodyus('bodyus')
}

if (document.all) {
eval( "document.all." + bodyfr + ".style.display = statebodyfr");
}
if (document.layers) {
document.layers[bodyfr].display = statebodyfr;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(bodyfr);
hza.style.display = statebodyfr;
}
}

</script>

<script language="javascript">

var statebodyus = 'none';
function showhidebodyus(bodyus) {

if (statebodyus == 'block') {
statebodyus = 'none';
}

else {
statebodyus = 'block';
}

if (document.all) {
eval( "document.all." + bodyus + ".style.display = statebodyus");
}
if (document.layers) {
document.layers[bodyus].display = statebodyus;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(bodyus);
hza.style.display = statebodyus;
}
}

</script>

<script language="javascript">

var statebodyfr2 = 'none';

function showhidebodyfr2(bodyfr) {

if (statebodyfr2 == 'block') {
statebodyfr2 = 'none';
}

else {
statebodyfr2 = 'block';
}

if (document.all) {
eval( "document.all." + bodyfr + ".style.display = statebodyfr2");
}
if (document.layers) {
document.layers[bodyfr].display = statebodyfr2;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(bodyfr);
hza.style.display = statebodyfr2;
}
}

</script>

<script language="javascript">

var statebodyus2 = 'block';

function showhidebodyus2(bodyus) {

if (statebodyus2 == 'block') {
statebodyus2 = 'none';
showhidebodyfr2('bodyfr')
}

else {
statebodyus2 = 'block';
showhidebodyfr2('bodyfr')
}

if (document.all) {
eval( "document.all." + bodyus + ".style.display = statebodyus2");
}
if (document.layers) {
document.layers[bodyus].display = statebodyus2;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(bodyus);
hza.style.display = statebodyus2;
}
}

</script>

</head>

<body>
<div id="bodyfr" style="display:block">
<table width="240" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="240" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>TITRE/LOGO fr</td>
</tr>
<tr>
<td>Contenu fr </td>
</tr>
<tr>
<td><a HREF="javascript:void(0)" onclick="showhide('divmapfr');">boutonmapfr</a></td>
</tr>
<tr>
<td>
<div id="divmapfr" style="display:none">
<table width="240" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>MAPfr </td>
</tr>
</table>
</div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>blabla fr </td>
</tr>
<tr>
<td>signaturefr </td>
</tr>
<tr>
<td><a HREF="javascript:void(0)" onclick="showhidebodyfr('bodyfr');">anglais</a></td>
</tr>
</table>
</div>

<div id="bodyus" style="display:none">
<table width="240" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="240" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>TITRE/LOGOus </td>
</tr>
<tr>
<td>Contenuus </td>
</tr>
<tr>
<td><a HREF="javascript:void(0)" onclick="showhide2('divmapus');">boutonmapus</a></td>
</tr>
<tr>
<td>
<div id="divmapus" style="display:none">
<table width="240" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>MAPus </td>
</tr>
</table>
</div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>blablaus </td>
</tr>
<tr>
<td>signatureus </td>
</tr>
<tr>
<td><a HREF="javascript:void(0)" onclick="showhidebodyus2('bodyus');">francais</a></td>
</tr>
</table>
</div>



</body>
</html>

Chorale
05-25-2010, 05:31 PM
Found the solution... Had to draw a paper chart to find the mistake lol :rolleyes: