Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-10-27
3
Medium Priority
?
116 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

721 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