This topic is locked

How do I clear a radio button

11/20/2007 2:43:51 AM
PHPRunner General questions
G
giles author

How do I clear a radio button?
I've tried using javascript with an ondblclick event with the following sntax...(I have all buttons identified by id...
function clearradiobutton(buttonid)

{

alert("clearing buttonid=" + buttonid)

document.getElementByID(buttonid).checked = false;

}
with button event set by...
document.getElementById("thebuttonid").ondblclick = function() {clearradiobutton("thebuttonid");};
The alert is telling me the event is being triggered but the button is not clearing...
Any ideas?

Alexey 11/20/2007

Hi,
here are some good sources about Javascript and DOM where you can find a solution:
http://www.w3schools.com/js/default.asp

http://msdn2.microsoft.com/en-us/library/ms533050.aspx

G
giles author 11/20/2007

Hi Alexey,

Thanks, I've been using those resources for some time.
In this case I can clear radio buttons in html pages created from scratch. Just can't clear radio buttons in html pages created by phprunner. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=23496&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
Is there a way to do this? (Doesn't have to be javascript.) Surely there must be a way without using the reset button because that resets all of the fields and is no use if a radio button is already checked. I've tried backspace, escape...Am I missing something basic here? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=23496&image=2&table=forumreplies' class='bbc_emoticon' alt=':blink:' />
Giles.

Alexey 11/21/2007

Giles,
pages created by PHPRunner are true HTML pages. So there is no difference in clearing radios on PHPRunner pages or your own.
Try using this code to clear radios:

var elems = document.getElementsByName('radio_FieldName');

for(i=0;i<elems.length;i++)

elems[i].checked=false;

document.forms.editform.value_FieldName.value='';


where FieldName is your actual field name.

G
giles author 11/22/2007

Thanks Alexey,
That works. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=23544&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />