Collecting a radio-button value in Classic ASP

Radio buttons are appropriate when the visitor should choose exactly one value from a group. Give every radio button in the group the same name and a different value.

<form method="post" action="radio-check.asp">
  <label><input type="radio" name="choice" value="yes"> Yes</label>
  <label><input type="radio" name="choice" value="no"> No</label>
  <button type="submit">Submit</button>
</form>

The receiving ASP page can read the selected value directly:

On this page — Show page sectionsHide page sections
Dim choice
choice = Request.Form("choice")
Response.Write Server.HTMLEncode(choice)

If no radio button is selected, the submitted value can be empty. Validate the result against the values your application allows instead of trusting arbitrary request text.

Allow only expected radio values

Dim choice
choice = Request.Form("plan")
Select Case choice
    Case "basic", "plus"
        Response.Write Server.HTMLEncode(choice)
    Case Else
        Response.Write "Choose a valid plan."
End Select

A visitor can change submitted form values. An allowlist protects the server-side workflow from unexpected options.

Always validate submitted choices

The browser can omit a radio value or submit a modified value. Check the value against an allowlist on the server before using it.

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer