473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

radiobuttons show/hide divs IE

Ciary
247 Expert 100+
hey all,

i have a problem with radio buttons showing and hiding divs in IE. i can't figure out what the problem is. when i click on the radiobutton nothing changes. it's only when i click somewhere else, it changes. can someone tell me how i can change it instantly.

here is a my html sample:
Expand|Select|Wrap|Line Numbers
  1. <form name='Sel'>
  2.    <input type='radio' name='selector' value='val1' id='val1' checked=true onchange='Change()'/>  //also tried onclick
  3.    <label>val1</label>
  4.    <input type='radio' name='selector' value='val2' id='val2' onchange='Change()'/>  //also tried onclick
  5.    <label>val2</label>
  6. </form>
  7. <div id='switchable1' style='display: block'>
  8.    <p>val1</p>
  9. </div>
  10. <div id='switchable2' style='display: none'>
  11.    <p>val2</p>
  12. </div>
and this is my javascript function:
Expand|Select|Wrap|Line Numbers
  1.             function Change(){
  2.                 if (document.Sel.selector[0].checked){
  3.                     $("switchable1").style.display = "block";
  4.                     $("switchable2").style.display = "none";
  5.                     accessSQL=true;
  6.                 }
  7.                 if (document.Sel.selector[1].checked){
  8.                     $("switchable1").style.display = "none";
  9.                     $("switchable2").style.display = "block";
  10.                     accessSQL=false;
  11.                 }
  12.             }
nice detail, it does work in FF.
May 15 '09 #1
11 2536
acoder
16,027 Expert Mod 8TB
That's because you're using onchange. Use onclick instead.
May 15 '09 #2
Ciary
247 Expert 100+
i thought so too therefor i tried it already. and it gives the same problem. it seems like IE only changes the checked value after the onclick- and onchange-event.
May 15 '09 #3
acoder
16,027 Expert Mod 8TB
I tested your code in IE6/7 using onclick and it worked fine.
May 20 '09 #4
RamananKalirajan
608 512MB
OnClick events works on both IE and Mozilla as well, The code what u had given is working in Mozilla...

Regards
Ramanan Kalirajan
May 20 '09 #5
Ciary
247 Expert 100+
well then i'm not sure what i'm doing wrong cause it doesn't work here. i've tried both onclick and onchange and nothing really changes.

to RamananKalirajan: yep, in mozilla it works fine. the problem lies with IE (as always, people should stop using it:p)
May 20 '09 #6
acoder
16,027 Expert Mod 8TB
Perhaps the problem is how your dollar $() function is defined. I just replaced that with document.getElementById().
May 20 '09 #7
Ciary
247 Expert 100+
never had any problem with prototype(cause it's a part from that framework), but i'll try as soon as possible. i dont have the code here atm so ill do it tomorrow.
May 20 '09 #8
acoder
16,027 Expert Mod 8TB
In that case, it may well be some other code on the page that's affecting things. If you just test the code you've posted, it should work.
May 21 '09 #9
Ciary
247 Expert 100+
ok, i solved the problem with onclick and still using prototype

how?: by restarting my computer :-o
???

i have no idea why it didn't work before and even less why it does now but it does and thats what matters.

ty acoder, ty Ramanan
May 21 '09 #10
acoder
16,027 Expert Mod 8TB
Oh, one of those! Restart the computer and everything works fine. Glad it's now working.
May 21 '09 #11
RamananKalirajan
608 512MB
May be its due to the temp variables and temp files.. that may be bothering you, but i am not sure.. I am glad that you got it working..

Regards
Ramanan Kalirajan
May 22 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: David | last post by:
Hi everyone, Hoping there are some .js/browser experts out there that can help with this weird problem. I have made a swap div routine and applied the events to menu buttons with a closer...
4
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers)...
5
by: dje | last post by:
In the OnClick event on a radioButtonList, I run a javascript to show/hide the appropriate div along with a submit button, which displays as expected. The problem is the submit no longer works on...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
1
by: asilverpeach | last post by:
Hey Guys! Found some great scripts here on this topic but have to make to changes to the code that I can't seem to figure out. First, In the following code clicking on the headers shows the...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
2
by: dusk | last post by:
Hi, I have a page with lots of hidden divs which are revealed based on choices made at each 'layer'. So I've used naming convention which represents the order in which each div becomes...
18
by: ryrocks | last post by:
Hi, Im making a 'contact us' page. The user click on the div, this then reveals another larger div displaying more information giving the effect of the box expanding or dropping down. I have 3...
5
by: Mike P | last post by:
How would I show or hide a div that is using client side Javascript based upon a server side variable? Here are my divs : <div id="idButton5" class="otherLeftBarLink" onmouseover="javascript:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.