Hi all
I will explain and example my existing code and then explain what i would like it to do.
I used to have a select box which offered three options,
1) Please select
2) Option 1
3) Option 2
Option 1 and 2 are set to their own div tags respectively. When someone clicks on either of the two options the appropriate div tag becomes visible. Also, if the page is reloaded the page remembers what option and makes the appropriate div tag visible.
[code=html]
<script type=”text/javascript”>
var cur = 0;
function displayDiv(idx) {
if (cur==idx) return true;
document.getElementById(“div”+cur).style.display = “none”;
document.getElementById(“div”+idx).style.display = “block”;
cur = idx;
return true;
}
window.onload = function() {
return displayDiv(document.myForm.mySelect.selectedIndex);
document.myForm.submit()
return true;
}
</script>
</head>
<body>
<form name=”myForm” method=”post” action=”<?php echo $_SESSION[‘PHP_SELF’] ?>”>
<div id=”div1″ style=”display:none;”>
<table id=”debit” class=”formnu” border=’0′ cellspacing=”1″ cellpadding=”2″>
<tr>
<td colspan=”2″ align=’center’>
blah blah blah – option 1
</td>
</tr>
</table>
</div>
<div id=”div2″ style=”display:none;”>
<table id=”credit” class=”formnu” border=’0′ cellspacing=”1″ cellpadding=”2″>
<tr>
<td align=”right” width=”65%”>
blah blah blah – option 2
</td>
</tr>
</table>
</div>
<div id=”div0″>
</div>
What i would like the code to do is work from a radio button. i.e. if radio button option 1 is clicked option 1 div visible and if radio button option 2 clciked option 2 div visible.
Can annyone help?