[solved] Problem with Javascript. Name fields problem?

SAGO 18 Jan, 2012
Hi,

I'm having problems making javascript work. I especially mean the radiobuttons that don't get recognized (I think).

This won't work because of line 2$('radio0'). etc :
window.addEvent('domready', function() {

$('radio0').addEvent('click',  function{ alert('test'); });

$('toggle').addEvent('click', function(e){
        e = new Event(e);
        alert("clicked on link (toggle)");
        e.stop();
        });
});


When I remove the following line it works:
$('radio0').addEvent('click',  function{ alert('test'); });


See the form in action here: http://tiny.cc/7ux7l

I always see the following in the ERRORCONSOLE in Firefox:
Error: $('radio0') is null


When I remove that line it works and I now that because when I click the link, a alertbox appears.
And the alertbox doesn't work when the line about $('radio0') is added.

I really don't what's wrong. Any ideas.
I would really appreciate it.

Thanks.
GreyHead 19 Jan, 2012
Hi SAGO,

The $('input_id') syntax uses the element id (not the name). The ids of your radio buttons are radio01 and radio02.

Bob
SAGO 19 Jan, 2012
Thanks bob.
That was it!

I thought indeed that the name would be used.

This thread can be marked as solved.
This topic is locked and no more replies can be posted.