You are here: Re: Making check boxes active on selection of radio button... « HTML « IT news, forums, messages
Re: Making check boxes active on selection of radio button...

Posted by X l e c t r i c on 11/22/37 11:36

Ed Jay wrote:
"I ended up using a simple javascript to toggle the CSS display property
of a <div style="display:none";>. When I press button 5, the five new
choices suddenly appear as now-displayed checkboxes. See what I mean at
http://www.edbj.aes-intl.com/pg4disp.html. Click on any of the checkbox
or buttons."

Mark wrote:
"I havent managed to work out how to get the check boxes to become
disabled if I select a different radio button..."

I actually prefer Ed's DHTML version. You might want to consider that.
You could have the checkboxes for all "eight" (pun intended) days of the
week in one row, and have them appear when the fifth radio button is
clicked.

I added a conditional to the changeChek() function.

I'm just winging it on these form and element names. They have to be the
same as what you have in your server side program. If the checkboxes
there all have different names then what I'm doing will have to be
changed. Maybe put the names in an Array, run it through a loop, and use
the DOM. Or something like that.

Later, Art.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function changeChek()
{
for (var i = 0; i < document.fone.cone.length; i++)
{
if (document.fone.rone[4].checked == true)
{
document.fone.cone[i].disabled = false;
}
else
{
document.fone.cone[i].disabled = true;
document.fone.cone[i].checked = false;
}
}
}
function setForm()
{
document.fone.reset();
for (var i = 0; i < document.fone.cone.length; i++)
{
document.fone.cone[i].disabled = true;
}
}
//-->
</script>
</head>
<body>
<form action="" name="fone">
<div>
<input type="radio" name="rone" value="rad1" onclick="changeChek();"> 1
Come for the whole week
<p>
<input type="radio" name="rone" value="rad2" onclick="changeChek();"> 2
Come for the first weekend
<p>
<input type="radio" name="rone" value="rad3" onclick="changeChek();"> 3
Come for the last weekend
<p>
<input type="radio" name="rone" value="rad4" onclick="changeChek();"> 4
Come for the midweek days
<p>
<input type="radio" name="rone" value="rad" onclick="changeChek();"> 5
Come for days that they specify
<p>
<input type="checkbox" name="cone" value="chek1" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek2" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek3" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek4" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek5" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek6" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek7" disabled="disabled">
<p>
<input type="checkbox" name="cone" value="chek8" disabled="disabled">
<p>
<input type="button" value="Reset" onclick="setForm();">
</div>
</form>
</body>
</html>

 

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

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