Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 119
  • Last Modified:

How do I select a default value on a radio button with Javascript?

I need a javascript to mark a radio button as checked on a form that I am creating.

Here is the radio button
<input id="PC69230_rdo_97_4" type="radio" name="PC69230$givingLevels" value="rdo_97_4" onclick="rdo_OnClick(this);">

Open in new window

0
dauyeung
Asked:
dauyeung
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
From:
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_radio_checked2
<script>
function check() {
    document.getElementById("PC69230_rdo_97_4").checked = true;
}
</script>

Open in new window

0
 
plusone3055Commented:
<input id="PC69230_rdo_97_4" type="radio" name="PC69230$givingLevels" value="rdo_97_4"  checked = "checked" onclick="rdo_OnClick(this);"
0
 
dauyeungAuthor Commented:
I removed the function call and it worked perfectly.  Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now