473,756 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using javascript with radio button to disable a text box - does not work in IE

Hi,
I am trying to use javascript, div tag and radio button to
disable/enable a text box. It works fine
in netscape and firefox, but in IE, the text box is not disabled when
the user checks the radio button.

Note that I am using two div statements. Any other solutions also
wellcome.

<html>
<title>Test</title>

<head>
<script type="text/javascript">

function checkButton(rNa me) {

collection = document.all[rName];
if (collection[1].checked)
{
//document.myform .abutton.disabl ed = true;
document.getEle mentById("durfi xed").style.dis play="block";
document.getEle mentById("nodur fixed").style.d isplay="none";
}
else
{
document.getEle mentById("durfi xed").style.dis play="none";
document.getEle mentById("nodur fixed").style.d isplay="block";
}

}
</script>
</head>

<body >
<h2>Radio Button Check</h2>

<form name=myform>
<fieldset style="width:10 0px">
<legend>Toggl e</legend>
<INPUT type=radio name=milestone value="Beta1"
onChange="check Button('milesto ne')">Beta 1<br>
<INPUT type=radio name=milestone checked value="Beta2"
onChange="check Button('milesto ne')">Beta 2<br>
</fieldset>

<br>

<div id="durfixed" style="display: block;" >
<input type=text name=ename value="">
</div>
<div id="nodurfixed " style="display: none;" >
<input type=text name=noename readonly value="" style="backgrou nd:
#cccccc" >
</div>
</body>
</form>
</html>
Thanks for the help
Siva

Aug 29 '06 #1
1 24747
s.********@gmai l.com wrote:
Hi,
I am trying to use javascript, div tag and radio button to
disable/enable a text box. It works fine
in netscape and firefox, but in IE, the text box is not disabled when
the user checks the radio button.
First, the solution: change your onchange to onclick.

Second, why. Your function is working in IE too. The difference is
tha in IE, the onchange event fires when the control loses focus (which
is as per the W3C spec) whereas other browsers fire a radio button's
onchange essentially as an onclick.

By using onclick, you'll get consistent behaviour across browsers.
Note however that using reload, it is possible to have the state of the
text input out of sync with the radio button selection in some (most?)
browsers. onload you should either run checkButton() or reset the form
to a known state.
--
Rob

Aug 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
20460
by: Raghuram Banda | last post by:
Hi, Can any one help me, how to create a Radio button using DOM with default one option is selected Thanks in advance
1
6163
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there are no instructions on how to make checkboxes and radio buttons required. I've tried adding these to my form, but I'm having no luck. Anyone know how to add radio buttons and checkboxes using the existing code mentioned on the url? Thank you!
1
1637
by: john | last post by:
I have two different problems: 1. When the user has clicked on a button that is causing the browser to post back to the server, it could take a little while for the new page to show up. So in the mean time, I want to change the cursor to an hourglass and disable all of the controls on the form using javascript so the user can't do anything with any of the controls on the page. But when I disable certain controls (e.g. text boxes, radio...
1
6428
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ? I'm posting my code below. The problem is that if i click on "AdjustThisAd" button, it opens...
9
4381
by: Marc | last post by:
Okay, here's the problem - I have 3 radio buttons, and 11 check boxes (which are disabled by default). I have the javascript below which when the last radio button is clicked, enables the checkboxes. <script type="text/javascript"> //<!]> </script> I used the JavaScript on 2 pages, on almost identical forms, and for some reason it doesn't work on the 2nd one - they just stay disabled,
8
4685
by: stefano | last post by:
HI, I have aproblem with XHTML radio button. <form name=" form"> <input name="radio" type="radio" onclick="return false" /> <input name="radio" type="radio" onclick="return false" /> <input name="radio" type="radio" onclick="return false" /> </form> I want that when the radio is clicked, it is not checked. in other word I want the click has no effect on the radio.
10
6103
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION.'");</SCRIPT>'; //? <snip of code>
1
108772
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back button anyways, if the user ventures away from your page then they wouldn't have this button at their disposal. The main reason people ask how to control or disable the back button is because they have a need to control sensitive (and/or) dynamic web...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10032
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9841
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9711
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.