Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click method not working

Status
Not open for further replies.

AAshcroft

Programmer
Joined
Oct 28, 2001
Messages
5
Location
CA
Hello,


I am trying to select a radio button from within JavaScript. The set of radio buttons have all been given the same name (QEDataEntry). I have tried the obvious, the click method, to no avail. I have tried the following:

document.form1.QEDataEntry[4].click;
document.form1.elements[4].click;

My browser is IE 5.5.

The reason I am trying to do this is that the page is normally reset when a new radio button is selected - however, if there was an error in the data entered within a set of textboxes (my JavaScript function tests for this), then the page is not reset, an alert is given, and the orignial radio button should be selected again from within JavaScript.

Any help would be appreciated!


Alan Ashcroft
 
its .onClick or groupName.onChange -Greg :-Q

flaga.gif
 
Thanks for responding, Greg, but what I'm actually trying to do is dynamically select an existing radio button (not just test to see if it has been selected). The click method does not work - neither does setting the checked property to True.

- Alan

 
document.formName.groupName.elementName.checked = "true" should work -Greg :-Q

flaga.gif
 
I think that you have to un-check all of the radio buttons before doing that, I think it will leave a previous selection checked.

for (i in document.formName.groupName.elements)
i.checked=false;


I think that should work Robert Carpenter
questions? comments? thanks? email me!
eclipse_web@hotmail.com
Icq: 124408594
online.dll

AIM & MSN: robacarp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top