Solved

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

Posted on 2014-10-27
3
94 Views
Last Modified: 2014-10-27
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
Comment
Question by:dauyeung
3 Comments
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40406797
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
 
LVL 22

Expert Comment

by:plusone3055
ID: 40406807
<input id="PC69230_rdo_97_4" type="radio" name="PC69230$givingLevels" value="rdo_97_4"  checked = "checked" onclick="rdo_OnClick(this);"
0
 

Author Closing Comment

by:dauyeung
ID: 40406898
I removed the function call and it worked perfectly.  Thanks!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now