How can I write this as a JavaScript function?

Posted by Haluk on Stack Overflow See other posts from Stack Overflow or by Haluk
Published on 2010-04-10T18:15:24Z Indexed on 2010/04/10 20:23 UTC
Read the original article Hit count: 251

Filed under:
|

I have the following code snippet embedded into some of my divs so when those divs get clicked a certain radio button gets checked.

onclick="document.g1.city[0].checked=true;"

However I would like to convert the above call to a function call like below:

onclick="checkRadioButton(city[0]);"

And the function will be something like this

function checkRadioButton(input){
    document.g1.input.checked=true;
}

Is there a way I can accomplish this?

© Stack Overflow or respective owner

Related posts about XHTML

Related posts about JavaScript