Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8914565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:45:18+00:00 2026-06-15T04:45:18+00:00

I am using a PHP script, but say I had two radio buttons, right?

  • 0

I am using a PHP script, but say I had two radio buttons, right?

How could I actually execute code, such as (main intention | display a messagebox) upon selection of one or the other?

Say I had a radio button named RadioButton1, Once checked/selected, a message box would appear saying RadioButton1 Selected?

Is this possible through PHP alone? Or do I need to integrate an html page which posts to the PHP page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:45:19+00:00Added an answer on June 15, 2026 at 4:45 am

    Use Javascript for client side interaction like that. The code below listens for the onchange event and shows an alert().

    jsFiddle Demo

    <input type="radio" name="myradio" value="RadioButton1" />
    <input type="radio" name="myradio" value="RadioButton2" />
    <input type="radio" name="myradio" value="RadioButton3" />
    
    <script>
    ​window.onload = function()
    {
        var radios = document.getElementsByName("myradio");
         for(var i=0; i<radios.length; i++)
         {
            radios[i].onchange = function()
            {
                if(this.checked)
                {
                    alert(this.value + " selected");
                }
            }
         }             
    }​
    </script>
    

    The first 3 lines are the radio buttons HTML. After that we have the <script> tag which denotes Javascript code. The Javascript is adding some code to the onload event, which simply means: execute this code when the page is loaded. Next we get all of the radio button elements into an array called radios – for that we use getElementsByName() passing the radio button group name which is myradio. Next we loop through each radio button in the array and assign an onchange handler, which means: execute this code when each radio button is changed. Within that, we check if the radio button is checked and if it is, we show the alert, showing the radio button’s value which will be RadioButton1, RadioButton2, RadioButton3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using old php script that depends on session_register to gives warning messages but
I need to handle strings in my php script using regular expressions. But there
How do I check that the php script works? I'm using php -f filename.php
Is it possible to make changes in mysql's my.ini file using PHP script?
I'm using a PHP script to generate an excel CSV file from a result-set
i am using a php script to automate posts to twitter. the script to
I'm using a PHP script with SimpleXML to parse an XML feed. I have
I am indexing a pdf file using this php script. The curl give me
I want to display an image using this php script on my server. $file
I am using wget in php script to download images from the url submitted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.