...

View Full Version : input type=radio, accompanying text



BubikolRamios
07-29-2010, 07:07 PM
Tutor:
http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_RADIO.html

Is there any uncomplicated way, that allso clicking on actual text "small, medium, ..."
would make option checked ?

VIPStephan
07-29-2010, 08:11 PM
<label><input type="radio" name="pizzasize" value="s"> small</label>
or

<input id="pizza_small" type="radio" name="pizzasize" value="s"> <label for="pizza_small">small</label>

As a matter of fact, this is far better when it comes to accessibility and is better to styles with CSS (since you have an element more to address). You should always use labels with your form controls.

BubikolRamios
07-29-2010, 08:26 PM
Thanks. Was playing around with java script, but this is far better.

BubikolRamios
07-30-2010, 02:46 PM
1.Can you allso enlight me, how come that group of input-radio buttons normaly works as semaphore, that is if one is turn on all the rest are turned off.

2.That pulls up allso question, if having two groups of input-radio buttons on one form , how can one separate/disconnect them.

3.In case of labels, as in this post thread, that (1) somehow does not work.
Example: http://agrozoo.net/test.html

How to fix that ?

Edit: allso noticed that in IE does not work at all, in FF all radio buttons stays on permanently.

wildreason
07-30-2010, 02:55 PM
1.Can you allso enlight me, how come that group of input-radio buttons normaly works as semaphore, that is if one is turn on all the rest are turned off.

2.That pulls up allso question, if having two groups of input-radio buttons on one form , how can one separate/disconnect them.

3.In case of labels, as in this post thread, that (1) somehow does not work.
Example: http://agrozoo.net/test.html

How to fix that ?

Edit: allso noticed that in IE does not work at all, in FF all radio buttons stays on permanently.

You just need to add name="group" to each of the boxes that belong in the same group. So your code would look like this:



<div>



<div title="Triglav National Park, Slovenia, avertebrata (Jurij Dobravec, 1995)">

<input type="radio" id="r1" value="1" name="test">
<label for="r1">TNP avertebrata</label>
<a href="http://tnp.si/s/bio/nevr/nevret.htm"><img src="../img/g/link.png" alt=""></a>

</div>

<div title="Rulls about categorization of herbaceus plants in Slovenia (Uradni list RS, št. 103/2008 z dne 30. 10. 2008 )">

<input type="radio" id="r2" value="2" name="test">
<label for="r2">Herbaceus plants useful allso as food</label>
<a href="http://www.uradni-list.si/files/RS_-2008-103-04369-OB~P001-0000.PDF"><img src="../img/g/link.png" alt=""></a>

</div>

<div title="Rulls about categorization of herbaceus plants in Slovenia (Uradni list RS, št. 103/2008 z dne 30. 10. 2008 )">

<input type="radio" id="r3" value="3" name="test">
<label for="r3">Herbaceus plants - implementation forbidden</label>

<a href="http://www.uradni-list.si/files/RS_-2008-103-04369-OB~P001-0000.PDF"><img src="../img/g/link.png" alt=""></a>

</div>

<div title="Rulls about categorization of herbaceus plants in Slovenia (Uradni list RS, št. 103/2008 z dne 30. 10. 2008 )">

<input type="radio" id="r4" value="4" name="test">
<label for="r4">Herbaceus plants - without prescription</label>
<a href="http://www.uradni-list.si/files/RS_-2008-103-04369-OB~P001-0000.PDF"><img src="../img/g/link.png" alt=""></a>

</div>


<div title="Rulls about categorization of herbaceus plants in Slovenia (Uradni list RS, št. 103/2008 z dne 30. 10. 2008 )">

<input type="radio" id="r5" value="5" name="test">
<label for="r5">Herbaceus plants - only with prescription</label>
<a href="http://www.uradni-list.si/files/RS_-2008-103-04369-OB~P001-0000.PDF"><img src="../img/g/link.png" alt=""></a>

</div>



</div>

BubikolRamios
07-30-2010, 03:23 PM
Aha. Thanks.
I have read sopmewhere that id is preffered ower name or name is even obsolute. So since then avoiding name. I guess in this case this is not so.

Kor
07-30-2010, 03:49 PM
Aha. Thanks.
I have read sopmewhere that id is preffered ower name or name is even obsolute. So since then avoiding name. I guess in this case this is not so.
Well, somehow it is true. name is ambiguous. You may have a single element with a certain name, but you may have also several elements with the same name. id is straight: it has to be unique.

On the other hand, radio groups need, by construction, the same name, in order to act like a group. Forms' elements need also a certain name, to be submitted. id is not enough.

Till the end, W3C reached a compromise.The name continues to be used along the id, but only for the form's elements.

VIPStephan
07-30-2010, 05:01 PM
<input type="radio" name="group1" />
<input type="radio" name="group1" />
<input type="radio" name="group1" />


<input type="radio" name="group2" />
<input type="radio" name="group2" />
<input type="radio" name="group2" />


You can see that of these six radio buttons three have a same name each. These are the ones that are related in that if one is selected the other one within that certain group deselected. The two different groups are independet, though.

Secondly, the name attribute is deprecated except for form controls (input, textarea, and select elements) because server side scripts use the names to process the input data. You can, for example, store the input data in an array it by giving the same name with square brackets to several (related) form controls. That can be useful if you have a form with several similar rows to enter contact data (i. e. phone numbers):



<input type="text" name="phone[]" />
<input type="text" name="phone[]" />
<input type="text" name="phone[]" />

… so a server side script can read the individual values like $_POST['phone'][2] (that’s PHP, for example).

Kor
07-30-2010, 08:39 PM
… so a server side script can read the individual values like $_POST['phone'][2] (that’s PHP, for example).
That is only in PHP. I don't think ASP is able to do that, at least not within the same syntax.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum