|
Posted by Jukka K. Korpela on 04/10/07 04:40
Scripsit frits:
> I have the following code:
>
> <input type="radio" id="q1" name="q1" value="Yes">
> <input type="radio" id="q1" name="q1" value="No">
That's odd, because
a) there is no explanation of what is being selected (no labels) - your real
page might have, but why didn't you post the URL of the real page?
b) there is no preselected button in the set, so if the user takes no action
on them, the submitted data depends on the browser (either no data from this
set or q1=Yes)
c) this is a Yes/No choice, which might be better presented as one
checkbox - assuming that it is useful to make a negative answer (no choice)
the default.
The id values shall be distinct, as Adrienne pointed out, but this problem
does not affect the question at hand. It would be particularly relevant
though if you added <label> elements with for="..." attributes.
> Now I want to check if the button q1 is used so the code must be
> extended.
Which button q1? There are two buttons you are calling q1. Maybe you meant
_a_ q1 button?
> When the button is not used, the value must be "q1 not
> used".
Then you would add e.g.
<label><input type="radio" name="q1" value="q1 not used" checked>(Please
select one of the above)</label>
> How can I do that? I will not use the "checked" option in the code if
> it is showed in the site.
You just painted yourself in the corner.
Oh well, you _could_ set display: none in CSS for the added element and hope
that all browsers treat an invisible radio button as an existing radio
button.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
[Back to original message]
|