Posts: 29
Name: Efthimios Arvanitis (call me Mike)
|
I rewrote the code a little, I hope it still functions as you need. Take a look at this and let me know if it does what you want. If not, we'll try again...
Here goes...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>How Many?</title>
</head>
<body>
<script type="text/javascript">
<!--
var divNum=0;
var howMany=3; // set how many divs you have
function showDivs(obj) {
var i, num;
divNum = parseInt(obj.options[obj.selectedIndex].value);
for(i=1; i<=howMany; i++) {
num = (i<howMany+1) ? "0"+i : i;
if(document.getElementById('div'+num)) { // if the div exists.
if(i<=divNum) {// display.
document.getElementById('div'+num).style.display="block";
} else { // hide.
document.getElementById('div'+num).style.display="none";
}
}
}
}
function hideAllDivsOnLoad(){
showDivs(document.getElementById("howmany"));
}
addLoadEvent(hideAllDivsOnLoad);
// add an onload event without destroying any previously set onload functions.
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
//-->
</script>
<table id="topTable" border="0" width="100%">
<tr>
<td>
How Many?
<select size="1" id="howmany" onchange="showDivs(this)">
<option value="0" selected>-Select-</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
</select></td>
</tr>
</table>
<div id="div01">
<table id="1st" border="0" width="100%">
<tr>
<td>1</td>
</tr>
</table>
</div>
<div id="div02">
<table id="2nd" border="0" width="100%">
<tr>
<td>2</td>
</tr>
</table>
</div>
<div id="div03">
<table id="3rd" border="0" width="100%">
<tr>
<td>3</td>
</tr>
</table>
</div>
</body>
</html>
__________________
█ Please login or register to view this content. Registration is FREE : SHARED & RESELLER · VPS & DEDICATED · DOMAIN NAMES · SERVER MANAGEMENT
█ PHP 4 & 5 · cPanel · Fantastico · RVSkin · Flash Tutorials · WHM-Reseller · FREE Billing Software!
Last edited by URLhost arvo; 07-10-2007 at 04:16 PM..
|