flyersun
07-08-2007, 12:01 AM
MY javascript knowlege is a little well non existant so I'm flying a little blind with the help of a few tutorals. What I'm trying to do is change the visible page content depending on what option is selected from a drop down menu. Bit it doesn't seem to be working.
Does anyone have any ideas why ?
Javascript Code
function showtypeinfo(){
if(this.text=="single"){
document.getElementById('normal').style.visibility = 'visible';
document.getElementById('backpackers').style.visibility = 'hidden';
document.getElementById('annual').style.visibility = 'hidden';
} else if (this.text=="annnual"){
document.getElementById('annual').style.visibility = 'visible';
document.getElementById('backpackers').style.visibility = 'hidden';
document.getElementById('single').style.visibility = 'hidden';
document.getElementById('independent').style.visibility = 'hidden';
} else if (this.text=="independent"){
document.getElementById('annual').style.visibility = 'hidden';
document.getElementById('backpackers').style.visibility = 'hidden';
document.getElementById('single').style.visibility = 'hidden';
} else if (this.text=="backpacker"){
document.getElementById('backpackers').style.visibility = 'visible';
document.getElementById('annual').style.visibility = 'visible';
document.getElementById('single').style.visibility = 'visible';
document.getElementById('independent').style.visibility = 'visible';
}
}
HTML Code (some of it)
<body onload="showtypeinfo();">
<form action="workout.php" method="post">
<table border="1">
<tr>
<td colspan="9">Trip Type</td>
</tr>
<td colspan="9">
<select name="triptype" onchange="showtypeinfo(this.value)">
<option value="single">Single Trip</option>
<option value="singlew">Single Trip with Winter Sports (12.5% added)</option>
<option value="annual">Annual Trip (upto 59 days)</option>
<option value="annualw">Annual Trip with Winter Sports (Price doubled) (upto 59 days)</option>
<option value="independent">Independent/ Long Stay Single Trip (More than 59 days)</option>
<option value="independentw">Independent/ Long Stay Single Trip Winter Sports (Price doubled) (More than 59 days)</option>
<option value="backpacker">Backpacker</option>
</select>
</td>
<tr>
<td colspan="9" id="backpacker">Destination (backpacker)</td>
</tr>
<tr>
<td colspan="9" id="backpacker">
<select name="dbp">
<option value="europe">Europe</option>
<option value="ausandnewzealand">Australia and New Zealand</option>
<option value="worldwide">Worldwide </option>
</select>
</td>
If you can work out whats wrong that would be soo great! it's going to make me hours otherwise and it's probably something really stupid.
Does anyone have any ideas why ?
Javascript Code
function showtypeinfo(){
if(this.text=="single"){
document.getElementById('normal').style.visibility = 'visible';
document.getElementById('backpackers').style.visibility = 'hidden';
document.getElementById('annual').style.visibility = 'hidden';
} else if (this.text=="annnual"){
document.getElementById('annual').style.visibility = 'visible';
document.getElementById('backpackers').style.visibility = 'hidden';
document.getElementById('single').style.visibility = 'hidden';
document.getElementById('independent').style.visibility = 'hidden';
} else if (this.text=="independent"){
document.getElementById('annual').style.visibility = 'hidden';
document.getElementById('backpackers').style.visibility = 'hidden';
document.getElementById('single').style.visibility = 'hidden';
} else if (this.text=="backpacker"){
document.getElementById('backpackers').style.visibility = 'visible';
document.getElementById('annual').style.visibility = 'visible';
document.getElementById('single').style.visibility = 'visible';
document.getElementById('independent').style.visibility = 'visible';
}
}
HTML Code (some of it)
<body onload="showtypeinfo();">
<form action="workout.php" method="post">
<table border="1">
<tr>
<td colspan="9">Trip Type</td>
</tr>
<td colspan="9">
<select name="triptype" onchange="showtypeinfo(this.value)">
<option value="single">Single Trip</option>
<option value="singlew">Single Trip with Winter Sports (12.5% added)</option>
<option value="annual">Annual Trip (upto 59 days)</option>
<option value="annualw">Annual Trip with Winter Sports (Price doubled) (upto 59 days)</option>
<option value="independent">Independent/ Long Stay Single Trip (More than 59 days)</option>
<option value="independentw">Independent/ Long Stay Single Trip Winter Sports (Price doubled) (More than 59 days)</option>
<option value="backpacker">Backpacker</option>
</select>
</td>
<tr>
<td colspan="9" id="backpacker">Destination (backpacker)</td>
</tr>
<tr>
<td colspan="9" id="backpacker">
<select name="dbp">
<option value="europe">Europe</option>
<option value="ausandnewzealand">Australia and New Zealand</option>
<option value="worldwide">Worldwide </option>
</select>
</td>
If you can work out whats wrong that would be soo great! it's going to make me hours otherwise and it's probably something really stupid.