Menu
I am creating a survey. It is located at [url]http://www.advanced1.net/Marketing/MRS.htm.
This is fairly urgent so any help would be greatly appreciated. Thanks George
var optionText = "Most Important,Imporant,Kind of,Not Very,Least Imporant "
optionText = optionText.split(",")
var nLists = 4; // number of select lists
var priorClip = false;
function restoreOptions(){
for (i=1; i<nLists+1; i++)
{
isList = document.getElementById(i);
isList.options.length = 1;
}
for (i=1; i<nLists+1; i++)
{
isList = document.getElementById(i);
for (n=0; n<5; n++)
{
isData = new Option(optionText[n],optionText[n]);
isList.add(isData,isList.options.length)
}
}
priorClip = false;
}
function clipOptions(List,Opt){
index = parseInt(List)+1;
for (index; index<nLists+1; index++)
{
isList = document.getElementById(index);
isList.selectedIndex = Opt;
isList.remove(isList.selectedIndex);
isList.selectedIndex = 0;
}
priorClip = true;
}
function editOptions(isList,isChoice){
if (priorClip == true && isList == 1 && isChoice == 0)
{restoreOptions()}
if (priorClip == false && isList == 1 && isChoice != 0)
{
List = isList;
nOpt = isChoice;
clipOptions(List,nOpt)
}
if (priorClip == true && isList != '1')
{
List = isList;
nOpt = isChoice;
clipOptions(List,nOpt)
}
}
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
var oldS;//global for the cloned content
function rOpt(s,o){
var sel = document.getElementById('oDiv').getElementsByTagName('select');//the select collection
for(var i=0;i<sel.length;i++){//removes the correspondent option from the other select
if((sel[i].options.length==s.options.length)&&(sel[i]!=s)){
sel[i].removeChild(sel[i].options[o])
}
}
var oKep = s.options[o].cloneNode(s.options[o]);//clone the selected option
while(s.hasChildNodes()){//removes all focused select's options
s.removeChild(s.childNodes[0])
}
s.appendChild(oKep);//append the cloned selected option
s.options[0].selected = true;
}
function cloneS(){//clones and copy the initial content
oldS =document.getElementById('oDiv').cloneNode(document.getElementById('oDiv'))
}
function pasteS(){//restore the cloned initial content
document.getElementById('oDiv').parentNode.replaceChild(oldS,document.getElementById('oDiv'))
cloneS();
}
onload=cloneS
</script>
</head>
<body>
<div id="oDiv">
<select name="whichever1" onchange="rOpt(this,this.selectedIndex)">
<option selected>-- Make a selection --</option>
<option value='Most important'>Most important</option>
<option value='Important'>Important</option>
<option value='Kind of'>Kind of</option>
<option value='Not very important'>Not very important</option>
<option value='Least important'>Least important</option>
</select><br>
<select name="whichever2" onchange="rOpt(this,this.selectedIndex)">
<option selected>-- Make a selection --</option>
<option value='Most important'>Most important</option>
<option value='Important'>Important</option>
<option value='Kind of'>Kind of</option>
<option value='Not very important'>Not very important</option>
<option value='Least important'>Least important</option>
</select><br>
<select name="whichever3" onchange="rOpt(this,this.selectedIndex)">
<option selected>-- Make a selection --</option>
<option value='Most important'>Most important</option>
<option value='Important'>Important</option>
<option value='Kind of'>Kind of</option>
<option value='Not very important'>Not very important</option>
<option value='Least important'>Least important</option>
</select><br>
<select name="whichever4" onchange="rOpt(this,this.selectedIndex)">
<option selected>-- Make a selection --</option>
<option value='Most important'>Most important</option>
<option value='Important'>Important</option>
<option value='Kind of'>Kind of</option>
<option value='Not very important'>Not very important</option>
<option value='Least important'>Least important</option>
</select><br>
<select name="whichever5" onchange="rOpt(this,this.selectedIndex)">
<option selected>-- Make a selection --</option>
<option value='Most important'>Most important</option>
<option value='Important'>Important</option>
<option value='Kind of'>Kind of</option>
<option value='Not very important'>Not very important</option>
<option value='Least important'>Least important</option>
</select><br>
<a href="#" onclick="pasteS();return false">Restore the initial options</a> </div>
</body>
</html>
[/code]
0.1.9 — BETA 6.17