views:

44

answers:

4

I'm trying to hide or show a div based on the value of some radio buttons, css defaults the div to display='none'

Here's the input

<input type="radio" id="payment_type" value="cash" checked="checked" name="payment_type" onchange="showhideFinancing(this.value);"/>&nbsp;Cash/Debit
<input type="radio" id="payment_type" value="cheque" name="payment_type" onchange="showhideFinancing(this.value);"/>&nbsp;Cheque
<input type="radio" id="payment_type" value="visa" checked="checked" name="payment_type" onchange="showhideFinancing(this.value);"/>&nbsp;VISA
<input type="radio" id="payment_type" value="mc" name="payment_type" onchange="showhideFinancing(this.value);"/>&nbsp;Mastercard
<input type="radio" id="payment_type" value="financing" name="payment_type" onchange="showhideFinancing(this.value);"/>&nbsp;Financing

Here's the div:

<div id="financing">
...
</div>

My Javascript fn looks like this:

function showhideFinancing(payment_type) {
    if (payment_type == "financing") {
        document.getElementById("financing").style.display = 'block';
    } else {
        document.getElementById("financing").style.display = 'none';
    }
}

Firebug shows that getElementById is not defined--Thanks!

A: 

Hmmm are you sure you got the IDs right? Check for duplicates. It's hard to tell without seeing the actual code.

Hal
A: 

Everything seems solid here. If you're getting a getElementById() is not defined then it will probably be either a typo or some missing syntax like mismatched brackets. You can assume that your html is right for now, focus on the script tag or file where the function is defined I'm pretty sure your problem lies in there.

Post more of that code to get more help.

Shaded
A: 

The code you have there, line for line, works for me in Safari. getElementByID is like part of the root implementation of the DOM; if its not defined I think you have problems with Firefox.

http://firefiter.com/temp.php

peelman
A: 

The only reasons I can think that it might be saying "getElementById" is not defined is if either you made a typo in your original code that you didn't while putting the sample up here (case sensitive is always the one that gets me) or if you have somehow redefined document elsewhere in the page.

Chris
talk about making a mountain of of a mole hill... that's what it was case... thanks man cheers!
Mikey1980