DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Discuss "Display Radio Button Value onclick" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Closed Thread « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old March 21st, 2008, 11:33 AM
New Member

 
Join Date: Mar 2008
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
theChris is an unknown quantity at this point
Default Display Radio Button Value onclick

Hi,

Is there easy way to dispaly the value of a radio button when it is clicked?

Thanks,

theChris

Last edited by richyrich; May 6th, 2008 at 11:58 AM. Reason: Removed [SOLVED] from title
Sponsored Links
  #2 (permalink)  
Old March 21st, 2008, 11:36 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 530
Thanks: 14
Thanked 38 Times in 37 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead is on a distinguished road

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

You can have such code:

Code:
<script language="javascript" type="text/javascript">
<!--
function displayValue()
{
 for (var i = 0; i < document.form1.radiobut.length; i++)
   {
    if (document.form1.radiobut[i].checked)
     {    
      var display = document.form1.radiobut[i].value;
      alert(display);
      
     }
   }
}
//-->
</script>
Above, replace "form1" and "radiobut" with the names of your form and radiobutton.
__________________
jmurrayhead
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
  #3 (permalink)  
Old March 21st, 2008, 12:57 PM
don94403's Avatar
Moderator


 
Join Date: Mar 2008
Location: San Mateo, CA, USA
Posts: 43
Thanks: 2
Thanked 3 Times in 3 Posts
Blog Entries: 2
Rep Power: 1
don94403 is on a distinguished road

Awards Showcase
Microsoft Access PHP 
Total Awards: 2

Default

Quote:
Originally Posted by theChris View Post
Hi,

Is there easy way to dispaly the value of a radio button when it is clicked?

Thanks,

theChris
Not quite sure what you want to do--display something to the user when he/she selects one choice among several? Would this be to confirm that the choice has been made? Usually just the black dot in the option selected is taken as the indication that the choice has been made. Or am I missing your point?
  #4 (permalink)  
Old March 21st, 2008, 01:00 PM
New Member

 
Join Date: Mar 2008
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
theChris is an unknown quantity at this point
Default

Quote:
Originally Posted by don94403 View Post
Not quite sure what you want to do--display something to the user when he/she selects one choice among several? Would this be to confirm that the choice has been made? Usually just the black dot in the option selected is taken as the indication that the choice has been made. Or am I missing your point?
It's simply for troubleshooting purposes, I just want to see if there is an easy way using JavaScript to display the value of the selected radiobutton.
  #5 (permalink)  
Old March 22nd, 2008, 11:20 AM
keep_it_simple's Avatar
KIS

 
Join Date: Mar 2008
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 1
keep_it_simple is on a distinguished road

Awards Showcase
Classic ASP 
Total Awards: 1

Default

Quote:
Originally Posted by theChris View Post
It's simply for troubleshooting purposes, I just want to see if there is an easy way using JavaScript to display the value of the selected radiobutton.

yes...if simply wanting to debug then you can use inline code

HTML Code:
<html>
 <head>
  <title>Javascript onclick Radio Button Demo</title>
 </head>
 <body>
  <form action="page.htm" method="post">
   <fieldset>
    <legend>Gender</legend>
     <table>
      <tr>
       <td>Male</td>
       <td><input type="radio" name="gender" value="Male" onclick="alert(this.value);"></td>
      </tr>
      <tr>
       <td>Female</td>
       <td><input type="radio" name="gender" value="Female" onclick="alert(this.value);"></td>
      </tr>
     </table>
   </fieldset>
  </form>
 </body>
</html> 

Comments on this post
theChris agrees:
  #6 (permalink)  
Old March 22nd, 2008, 02:28 PM
New Member

 
Join Date: Mar 2008
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
theChris is an unknown quantity at this point
Default

Thanks guys, both solutions worked
Closed Thread

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 07:47 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46