Solved

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

Posted on 2014-10-27
3
104 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 40

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
innerHTML 7 35
How do I show metrics with PHP or Javascript 6 34
JQuery Syntax... 4 38
javascript - insert into js doc help 2 25
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

820 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