is it possible to set the radio button disabled on clicking the submit button

Recommended Answers

All 3 Replies

Yes, but you need to use 'onSubmit' in the form tag to change the radio button to be disabled. A sample code is below...

<html>
<head>
  <script type="text/javascript">
  function demo(form) {
    var rads = form.radd
    for (var i=0; i<rads.length; i++) {
      rads[i].disabled = true
    }

    return true
  }
  </script>
</head>
<body>
  <form action="200.html" onsubmit="return demo(this)">
    <input type="radio" name="radd" value="rad1">Radio1
    <input type="radio" name="radd" value="rad2">Radio2
    <input type="radio" name="radd" value="rad3">Radio3
    <input type="radio" name="radd" value="rad4">Radio4
    <br><br>
    <input type="submit" value="Go Ahead">
  </form>
</body>
</html>

The code assume that the next page is going to be 200.html...

Yes it is possible to make the radio button disabled using javascript but the problem will be that the radio button's value wont be submitted to server if it is disabled. You will have to use some hidden fields to pass the value to the server

Thank U

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.