Indeed, by their very nature you should not have dupe ids on a page.




"This e-mail is from Reed Exhibitions (Gateway House, 28 The Quadrant,
Richmond, Surrey, TW9 1DN, United Kingdom), a division of Reed Business,
Registered in England, Number 678540.  It contains information which is
confidential and may also be privileged.  It is for the exclusive use of the
intended recipient(s).  If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful.  If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910.  The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions." 
Visit our website at http://www.reedexpo.com

-----Original Message-----
From: Charlie Griefer
To: CF-Talk
Sent: Wed Jan 10 00:19:47 2007
Subject: Re: JS and Radio Button Issue

few things i can see would be a problem.

you have multiple elements with ids "with" and "without" (the radio
buttons and the divs).

the code below should work.

<script language="JavaScript">
        function toggle(divToShow) {
                if (document.getElementById) {
                        if (divToShow == "with") {
        
document.getElementById('withdiv').style.display = "inline";
        
document.getElementById('withoutdiv').style.display = "none";
                        } else {
        
document.getElementById('withdiv').style.display = "none";
        
document.getElementById('withoutdiv').style.display = "inline";
                        }
                }
        }
</script>

<input type="radio" name="VBM" value="1" id="with"
onclick="toggle('with')" /> With
<br /><br />
<input type="radio" name="VBM" value="2" id="without"
onclick="toggle('without')" /> Without

<br /><br />

<div id="withdiv" style="display:none;">
        With vote by mail options here
</div>
<div id="withoutdiv" style="display:none;">
        without vote by mail options here
</div>

On 1/9/07, Bruce Sorge <[EMAIL PROTECTED]> wrote:
> I have a form that has two radio buttons. Their function is to show one of
> two hidden divs.
> The JS is this:
> <script language="JavaScript">
> function toggle('with', 'without')
> {
> if (document.getElementById) {
> withvbm= document.getElementById('with');
> withoutvbm= document.getElementById('without');
> }
>
> if (withvbm.style.display == "none"){
> withvbm.style.display = "";
> withoutvbm.style.display = "none";
> }
>
> else if (withoutvbm.style.display == "none"){
> withoutvbm.style.display = "";
> withvbm.style.display = "none";
> }
> }
> </script>
> The radio buttons look like this:
>  <input type="radio" name="VBM" value="1" id="with"
onclick="toggle('with',
> 'without')">With<BR><BR>
>    <input type="radio" name="VBM" value="2" id="without"
> onclick="toggle('without', 'with')">With Out
>
> And the divs look like this:
>  <div id='with' style="display:none;">
>  With vote by mail options here
>  </div>
>  <div id='without' style="display:none;">
>  without vote by mail options here
>  </div>
> When I click either button, I get an error that and Object is expected.
The
> error is on the radio buttons. From what I can tell everything looks OK.
Can
> anyone see any issues with this? Also, I tried changing the first div's
> style to display:block assuming that the page needed to see one of them
and
> of it did not work, but then I though no, that cannot be it since I want
> both div's hidden until the user clicks one of the buttons.
>
> Thanks,
> --
> Bruce Sorge
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266109
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to