Radio Button List server control and java script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jayuya

    #1

    Radio Button List server control and java script

    How can i check in java script if a asp.net radio button
    list server control is selected?

    I have some custom javascript function in the client side
    that needs to run but I don't see the way to see if user
    selected or not one of the options....

    thanks,
    jayuya
  • David Waz...

    #2
    Radio Button List server control and java script

    The aspx control obviously renders as normal HTML. Use
    the ID/Name of the html control as usual.

    An easy way to get the HTML name:
    htmlName=replac e(RadioButtonCo ntrol.UniqueNam e,":","_")

    [color=blue]
    >-----Original Message-----
    >How can i check in java script if a asp.net radio button
    >list server control is selected?
    >
    >I have some custom javascript function in the client side
    >that needs to run but I don't see the way to see if user
    >selected or not one of the options....
    >
    >thanks,
    >jayuya
    >.[/color]

    Comment

    • Vidar Petursson

      #3
      Re: Radio Button List server control and java script

      Hi

      Example ( Should work... I did not check :) )

      Replace FORMNAME/RADIONAME with yours
      <html>
      <head>
      <script language="JavaS cript">
      function checkRadio(){
      var bIsChecked = false;
      var r = document.forms["myForm"].r1;
      for(i=0;i<r.len gth;i++)
      {
      if( r[i].checked )
      {
      bIsChecked = true;
      break;
      }
      }
      if(!bIsChecked ) alert("Please check.... ");
      return bIsChecked;
      }
      </script>
      </head>
      <body>
      <form name="myForm">
      <input type="radio" name="r1">
      <input type="radio" name="r1">
      <input type="radio" name="r1">
      <input type="radio" name="r1">
      <input type="radio" name="r1">
      <input type="submit" onclick="return checkRadio()" value="Click to test
      radio">
      </form>
      </body>
      </html>

      Note if for some reason the list has only 1 item the length will be
      undefined.

      And also we have a good group for client issues
      microsoft.publi c.scripting.jsc ript

      --
      Best Regards
      Vidar Petursson
      =============== ===============
      Microsoft Internet Client & Controls MVP
      =============== ===============
      "jayuya" <jayuya@cox.net > wrote in message
      news:03c501c341 95$51b31810$a10 1280a@phx.gbl.. .[color=blue]
      > How can i check in java script if a asp.net radio button
      > list server control is selected?
      >
      > I have some custom javascript function in the client side
      > that needs to run but I don't see the way to see if user
      > selected or not one of the options....
      >
      > thanks,
      > jayuya[/color]


      Comment

      Working...