This is a javascript job.
e.g.
<html>
<head>
<title>My dynamic page</title>
<script type="text/javascript">
function checkGender () {
var male, female, bustsize, ahemsize, gender;
male = document.getElementById('radio_select_m');
female = document.getElementById('radio_select_f');
bustsize = document.getElementById('bust_size');
ahemsize = document.getElementById('ahem_size');
if (male.checked) {
bustsize.disabled = true;
ahemsize.disabled = false;
} else if (female.checked) {
bustsize.disabled = false;
ahemsize.disabled = true;
}
}
</script>
</head>
<body>
<form name="myform" action="a_page.php" method="GET">
I am...<br />
Male <input type="radio" id="radio_select_m" name="gender_select" onmouseup="checkGender();" onkeyup="checkGender();" /><br />
Female<input type="radio" id="radio_select_f" name="gender_select" onmouseup="checkGender();" onkeyup="checkGender();" /><br />
<br />
Enter your bust size <input type="text" name="bust_size" id="bust_size" value="34C" /><br />
Enter the length of your personal area <input type="text" name="ahem_size" id="ahem_size" value="12 inches" /><br />
<br />
<input type="submit" value="Tell us some very personal information">
</form>
</body>
</html>
The best way to do this is with the 'onkeyup' and 'onmouseup' events, but the problem with these is that, at least in IE (evil evil evil) the 'checked' property is not changed until after the event has been called. This means that the first time you select something, the function effectively does nothing.
The alternative approach is to use the 'onchange' event, but this means that the function is not called until you change focus to another element, so nothing appears to happen until you try to do something else.
It's a bit catch 22 - probably the best compromise is to use 'onchange' as this will always work first time, just not until you try and do something else.
The other, always works, approach to that problem is this...
<script type="text/javascript">
function checkGender (exec) {
if (exec != undefined) {
setTimeout(checkGender,10);
return;
}
var male, female, bustsize, ahemsize, gender;
male = document.getElementById('radio_select_m');
female = document.getElementById('radio_select_f');
bustsize = document.getElementById('bust_size');
ahemsize = document.getElementById('ahem_size');
if (male.checked) {
bustsize.disabled = true;
ahemsize.disabled = false;
} else if (female.checked) {
bustsize.disabled = false;
ahemsize.disabled = true;
}
}
</script>
...
Male <input type="radio" id="radio_select_m" name="gender_select" onmouseup="checkGender(true);" onkeyup="checkGender(true);" />
...but it's a bit messy.
P.S. Apologies for being crude, but it's hard to resist when you are mentally 8 years old... 😉