Spider-Man
May 11th 2008, 6:37 am
Hey guys, freshly back from my recent ban (:() and have an issue with javascript.
Basically I have a piece of code like this:
<select name='PAYMENTMETHOD' size="1"
onChange="javascript:HideCCDetails(this)" >
Then a div, with a list box, and 4 fields. The list box, when option (with the value 10005 is selected, the fields should be displayed, otherwise they should be hidden.
<script language=javascript type='text/javascript'>
function hideDiv()
{
if (document.getElementById)
{ // DOM3 = IE5, NS6
document.getElementById('CCDetails').style.visibility = 'hidden';
}
else
{
if (document.layers)
{ // Netscape 4
document.CCDetails.visibility = 'hidden';
}
else
{ // IE 4
document.all.CCDetails.style.visibility = 'hidden';
}
}
}
function showDiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('CCDetails').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.CCDetails.visibility = 'visible';
}
else { // IE 4
document.all.CCDetails.style.visibility = 'visible';
}
}
}
function HideCCDetails(selectObj)
{
if (selectObj.options[selectObj.selectedIndex].value == "10005")
{
showDiv();
}
else
{
hideDiv();
}
}
</script>
How can I edit the second part of the script so that the <div> for CC details is hidden all the time, and it only shown when the object with the value 10005 is selected. It works at the moment, but not when the page first loads, I need the fields to be hidden when the page loads.
Any ideas?
Thanks:D
Basically I have a piece of code like this:
<select name='PAYMENTMETHOD' size="1"
onChange="javascript:HideCCDetails(this)" >
Then a div, with a list box, and 4 fields. The list box, when option (with the value 10005 is selected, the fields should be displayed, otherwise they should be hidden.
<script language=javascript type='text/javascript'>
function hideDiv()
{
if (document.getElementById)
{ // DOM3 = IE5, NS6
document.getElementById('CCDetails').style.visibility = 'hidden';
}
else
{
if (document.layers)
{ // Netscape 4
document.CCDetails.visibility = 'hidden';
}
else
{ // IE 4
document.all.CCDetails.style.visibility = 'hidden';
}
}
}
function showDiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('CCDetails').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.CCDetails.visibility = 'visible';
}
else { // IE 4
document.all.CCDetails.style.visibility = 'visible';
}
}
}
function HideCCDetails(selectObj)
{
if (selectObj.options[selectObj.selectedIndex].value == "10005")
{
showDiv();
}
else
{
hideDiv();
}
}
</script>
How can I edit the second part of the script so that the <div> for CC details is hidden all the time, and it only shown when the object with the value 10005 is selected. It works at the moment, but not when the page first loads, I need the fields to be hidden when the page loads.
Any ideas?
Thanks:D