from bbcline
Sorry to jump in on your thread but I’m new to this forum and didn’t want to just start a new thread.
Is it possible to limit choices in a drop down menu to attributes that were given a certain rating in a previous question? What I’d like to have is a question that asks a respondent to rate ten things on a scale of 1 to 5 (worst), then follow that up with a drop down menu with only the ones that got ratings of 4 or 5 and asks that you to choose the ONE that was the worst.
Basically I’d like to write add/remove choices to the menu based on what has already been answered. If no ratings of 4 or 5 are given then the drop down question will be skipped completely. If, out of the ten, there is one rating of 4 and one of 5, I would still have a drop down menu of those two, even though it would seem obvious that the one rated 5 is the one considered the worst.
I hope that makes sense. Any help would be appreciated.
Thanks.
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title></title>
<script language=”JavaScript” type=”text/javascript”>
/*<![CDATA[*/
function zxcAddSelects(zxcid,zxctid){
zxcp=document.getElementById(zxcid);
var zxcclds=zxcNoTxtNodes(zxcp);
for (var zxc0=0;zxc0<zxcclds.length;zxc0++){
var zxcsel=zxcES(‘SELECT’,{width:’100px’},zxcclds[zxc0]);
zxcsel.onchange=function(){ zxcRate(zxcid,zxctid); }
var zxcstar=”;
for (var zxc0a=0;zxc0a<5;zxc0a++){
zxcstar+=’*’;
zxcsel.options[zxc0a]=new Option(‘Rate ‘+zxcstar,zxcclds[zxc0].getElementsByTagName(‘SPAN’)[0].firstChild.data+’ ‘+zxcstar,true,true);
}
zxcsel.selectedIndex=0;
}
}
function zxcRate(zxcid,zxctid){
var zxcsels=document.getElementById(zxcid).getElementsByTagName(‘SELECT’);
var zxctarget=document.getElementById(zxctid)
zxctarget.options.length=0;
for (var zxc0=0;zxc0<zxcsels.length;zxc0++){
if (zxcsels[zxc0].selectedIndex>2){
zxctarget.options[zxctarget.options.length]=new Option(zxcsels[zxc0].value,zxcsels[zxc0].selectedIndex,true,true);
}
}
zxctarget.selectedIndex=0;
zxcES(zxctarget,{visibility:(zxctarget.options.length>0)?’visible’:hidden});
}
function zxcNoTxtNodes(zxcp){
if (typeof(zxcp)==’string’) zxcp=document.getElementById(zxcp)
var zxcclds=zxcp.childNodes,zxcary=[];
for (var zxca=0;zxca<zxcclds.length;zxca++){ if (zxcclds[zxca].nodeType!=1) zxcary.push(zxcclds[zxca]); }
for (var zxcb=0;zxcb<zxcary.length;zxcb++){ zxcp.removeChild(zxcary[zxcb]); }
return zxcclds;
}
function zxcES(zxcele,zxcstyle,zxcp,zxctxt){
if (typeof(zxcele)==’string’){ zxcele=document.createElement(zxcele); }
for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; }
if (zxcp){ zxcp.appendChild(zxcele); }
if (zxctxt){ zxcele.appendChild(document.createTextNode(zxctxt)); }
return zxcele;
}
/*]]>*/
</script></head>
<body onload=”zxcAddSelects(‘Questions’,’Rate’)”>
<div id=”Questions” >
<div ><span>Question 1</span></div>
<div ><span>Question 2</span></div>
<div ><span>Question 3</span></div>
<div ><span>Question 4</span></div>
</div>
<select id=”Rate” style=”visibility:hidden;width:150px;” ></select>
</body>
</html>