You are here: Re: [PHP] Validating Radio Buttons in two directions « PHP « IT news, forums, messages
Re: [PHP] Validating Radio Buttons in two directions

Posted by tedd on 10/04/03 11:37

>On Tue, 17 Jan 2006 10:45:01 -0500
>John Nichel <john@kegworks.com> wrote:
>>
>> Huh? Maybe I'm just not awake this morning and not understanding
>> what you're trying to explain, but if you're using *radio* buttons,
>> only *one* of the same name can be checked at any give time. ie:
>>
>> <input type="radio" name="color" value="1" /> Blue
>> <input type="radio" name="color" value="2" /> Red
>> <input type="radio" name="color" value="3" /> Black
>> <input type="radio" name="color" value="4" /> Green
>> <input type="radio" name="color" value="5" /> Mauve
>>
>> If you click "Red" and "Blue" is already selected, "Blue" will
>> automatically be unselected. It's basic HTML.
>
>That's not what he's trying to do. Grab some coffee #;-D


Thanks Ozz -- I was not in the mood to be wrong (again -- too much lately).

When I was confronted with a similar problem before, I used html/php/js:

<input type="radio" name="alter" onClick="return uncheckall(<?php
echo($what_button); ?>)">

Where the javascript was:

<script language="javascript">

function uncheckall(num)
{
var els=document.forms[0].elements;
for ( i=els.length; i--; )
{
if( els[i].type.toLowerCase() == 'radio' )
{
if (i != num)
{
els[i].checked = false;
}
}
}
els[num].checked = true;
document.alter; return false;
}
</script>

That way, when the user clicks any rank, all of the buttons within
that rank are unchcecked leaving only the most current checked.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация