radio button, check for use
I have the following code:
<input type="radio" id="q1" name="q1" value="Yes">
<input type="radio" id="q1" name="q1" value="No">
Now I want to check if the button q1 is used so the code must be extended.
When the button is not used, the value must be "q1 not used".
How can I do that? I will not use the "checked" option in the code if it is
showed in the site.
When there is a hidden "checked" option than the value of q1 is always "q1
not used" what can be a solution....
Frits
Re: radio button, check for use
"frits" <fsch01 [at] hotmail.com> wrote in message
news:593ad$461a98a8$503824ed$20645 [at] news.chello.nl...
|I have the following code:
|
| <input type="radio" id="q1" name="q1" value="Yes">
| <input type="radio" id="q1" name="q1" value="No">
|
| Now I want to check if the button q1 is used so the code must be extended.
| When the button is not used, the value must be "q1 not used".
|
| How can I do that? I will not use the "checked" option in the code if it
is
| showed in the site.
| When there is a hidden "checked" option than the value of q1 is always "q1
| not used" what can be a solution....
not sure what you're asking...however, this should give you three states of
q1:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?
$q1 = $_REQUEST['q1'];
if ($q1)
{
echo 'q1 ' . ($q1 == 'Yes' ? '' : 'not ') . 'used.';
} else {
echo 'q1 has not been set.';
}
?>
<form method="post">
<div>
<span style="width:100px;">Use Q1</span>
<span><input type="radio" name="q1" value="Yes" <?= ($q1 == 'Yes' ?
'checked' : '') ?>/></span>
</div>
<div>
<span style="width:100px;">Don't Use Q1</span>
<span><input type="radio" name="q1" value="No" <?= ($q1 == 'No' ?
'checked' : '') ?>/></span>
</div>
<div style="margin-top:20px;">
<input type="submit" value="Try It ..." />
</div>
</form>
Re: radio button, check for use
On Apr 10, 3:47=C2=A0am, "frits" <fsc... [at] hotmail.com> wrote:
> I have the following code:
>
> <input type=3D"radio" id=3D"q1" name=3D"q1" value=3D"Yes">
> <input type=3D"radio" id=3D"q1" name=3D"q1" value=3D"No">
>
> Now I want to check if the button q1 is used so the code must be extended.
> When the button is not used, the value must be "q1 not used".
>
> How can I do that? I will not use the "checked" option in the code if it =
is
> showed in the site.
> When there is a hidden "checked" option than the value of q1 is always "q1
> not used" what can be a solution....
>
> Frits
<?
$q1 =3D $_REQUEST['q1'];
?>
<input type=3D"radio" id=3D"q1" name=3D"q1" value=3D"Yes"
<?php if($q1 =3D=3D 'yse')
{
echo ' checked=3D"checked" ';
}
?>
>
<input type=3D"radio" id=3D"q1" name=3D"q1" value=3D"No"
<?php if($q1 =3D=3D 'no')
{
echo ' checked=3D"checked" ';
}
?>
>