/    Sign up×
Community /Pin to ProfileBookmark

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>[/CODE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 13.2007 — I hope that makes sense. Any help would be appreciated.[/QUOTE]Not really, could you give a practical example?

An observation: you use 'zxc' before all your objects. A better solution is YAHOO, namespace-your-javascript/
Copy linkTweet thisAlerts:
@bbclineJul 13.2007 — Not really, could you give a practical example?

An observation: you use 'zxc' before all your objects. A better solution is YAHOO, namespace-your-javascript/[/QUOTE]


Let's say you're asked to rate your satisfaction with several aspects of your job:

Q1) Very Satisfied (1) - Satisfied (2) - Neither (3) - Dissatisfied (4) - Very Dissatisfied (5)

a) Your salary

b) Benefits

b) Opportunities for growth/advancement

c) Working environment

e) Your manager/supervisor

f) Training provided

Any of these that are rated 'dissatisfied' or 'very dissatisfied', I want to put in a dropdown box in the next question that asks

Q2) "With which ONE of these are you most dissatisfied?"

I know I can put all six in the dropdown box but I'd rather only put the ones with which they are dissatisfied. If there are none, Q2 can be skipped. If only one, I'd still show it in a dropdown.

So, is there a way I can control for the variables a thru f being equal to 4 or 5 that will then limit the options in a dropdown box?

Thanks again.

BB
Copy linkTweet thisAlerts:
@bbclineJul 13.2007 — Vic, thanks, I'll give it a try.

Good luck in the Premiership this year.

BB
×

Success!

Help @vwphillips spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...