/    Sign up×
Community /Pin to ProfileBookmark

Radio buttons?

Hi, i cant remember how to get the value of the option box

I have 3 radio buttons on a page all called radio (so it unchecks one when another is ticked) but when i submit the page how do i know which on is checked i.e just get it to display on page

Let me know if you want more info

[CODE]
<input name=”radio” type=”radio” value=”radiobutton”>
[/CODE]

Cheers Adam

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 06.2004 — It's the "value" parameter in the input tag. Each radio button should have a unique value assigned to it. Then in your form handler code you check to see what value it has to determine what will be done.
Copy linkTweet thisAlerts:
@k0r54authorDec 07.2004 — Hi ok so for example

if i have a form with this in

<input name="radio" type="radio" value="1">

and a php page that the form links to with this in it

[code=php]
<?PHP
$Radio1 = $_POST[1];

echo "$Radio1";
?>
[/code]


Will that echo 1, (the value of the radio button 1)
Copy linkTweet thisAlerts:
@NogDogDec 07.2004 — Yes, however I would reference the _POST array associatively (much easier to maintain):

[code=php]
<?PHP
$Radio1 = $_POST['radio'];
echo "$Radio1";
?>
[/code]
Copy linkTweet thisAlerts:
@k0r54authorDec 07.2004 — Sorry, I should have updated the thread, i figured it out about 5 min after i posted it.

Thanks

Adam

P.S i do have another thread if you could possibly look at that
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...