Forums

PHP

This topic is locked

Allowing only one selection

Posted 07 Dec 2003 07:52:19
1
has voted
07 Dec 2003 07:52:19 Mark S posted:
I am trying to set up a form where i would show for example 10 fields, each field would be a checkmark, however i want each person to only be able to check one of them not multiple. Any ideas please?

Replies

Replied 12 Dec 2003 12:06:08
12 Dec 2003 12:06:08 goa103 goa103 replied:
Note : this topic should be moved to the HTML forum, it doesn't deal with PHP but HTML forms.

Use radio buttons instead of checkboxes. It only allows a visitor to pick one choice from many.

Radio example :
<pre id=code><font face=courier size=2 id=code>
&lt;form action="my_action.php" method="POST"&gt;
&lt;input type="radio" name="my_radio" value="0" checked&gt; My default radio&lt;br&gt;
&lt;input type="radio" name="my_radio" value="1"&gt; My radio 1&lt;br&gt;
&lt;input type="radio" name="my_radio" value="2"&gt; My radio 2&lt;br&gt;

&lt;input type="submit"&gt;
&lt;/form&gt;
</font id=code></pre id=code>

Same example with checkboxes :
<pre id=code><font face=courier size=2 id=code>
&lt;form action="my_action.php" method="POST"&gt;
&lt;input type="checkbox" name="my_radio" value="0" checked&gt; My default choice&lt;br&gt;
&lt;input type="checkbox" name="my_radio" value="1"&gt; My choice 1&lt;br&gt;
&lt;input type="checkbox" name="my_radio" value="2"&gt; My choice 2&lt;br&gt;

&lt;input type="submit"&gt;
&lt;/form&gt;
</font id=code></pre id=code>

Edited by - goa103 on 10 Nov 2008 00:25:16

Reply to this topic