Beste mede helpmij-ers,
ik heb een vraagje: Ik kwam een scriptje tegen op internet.
En wil deze gaan gebruiken voor mijn website. Alleen wil hem graag uitbreiden met 4 extra velden, maar zou niet weten hoe ik dat moet doen..
Wie kan me helpen???
alvast dank.
[JS]<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var OptLstTxt = new Array;
var OptLstVal = new Array;
var OptLen = 0;
function NoDupl(SelObjFrom, SelObjTo) {
var OldToVal = SelObjTo.options[SelObjTo.selectedIndex].value;
if (OptLen == 0) {
OptLen = SelObjFrom.length;
for (var i = 1; i < OptLen; i++) {
OptLstTxt = SelObjFrom.options.text;
OptLstVal = SelObjFrom.options.value;
}
}
var j = 1;
for (var i = 1; i < OptLen; i++) {
if (OptLstVal != SelObjFrom.options[SelObjFrom.selectedIndex].value) {
if (j == SelObjTo.length) {
SelObjTo.options[j] = new Option(OptLstTxt);
}
else {
SelObjTo.options[j].text = OptLstTxt;
}
SelObjTo.options[j].value = OptLstVal;
if (OptLstVal == OldToVal) {
SelObjTo.selectedIndex = j;
}
j++;
}
}
if (SelObjTo.length > j)
SelObjTo.options[(SelObjTo.length - 1)] = null;
}
// End -->
</script>[/JS]
ik heb een vraagje: Ik kwam een scriptje tegen op internet.
En wil deze gaan gebruiken voor mijn website. Alleen wil hem graag uitbreiden met 4 extra velden, maar zou niet weten hoe ik dat moet doen..
Wie kan me helpen???
alvast dank.
[JS]<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var OptLstTxt = new Array;
var OptLstVal = new Array;
var OptLen = 0;
function NoDupl(SelObjFrom, SelObjTo) {
var OldToVal = SelObjTo.options[SelObjTo.selectedIndex].value;
if (OptLen == 0) {
OptLen = SelObjFrom.length;
for (var i = 1; i < OptLen; i++) {
OptLstTxt = SelObjFrom.options.text;
OptLstVal = SelObjFrom.options.value;
}
}
var j = 1;
for (var i = 1; i < OptLen; i++) {
if (OptLstVal != SelObjFrom.options[SelObjFrom.selectedIndex].value) {
if (j == SelObjTo.length) {
SelObjTo.options[j] = new Option(OptLstTxt);
}
else {
SelObjTo.options[j].text = OptLstTxt;
}
SelObjTo.options[j].value = OptLstVal;
if (OptLstVal == OldToVal) {
SelObjTo.selectedIndex = j;
}
j++;
}
}
if (SelObjTo.length > j)
SelObjTo.options[(SelObjTo.length - 1)] = null;
}
// End -->
</script>[/JS]
HTML:
<form method="POST" name="MForm">
Try to select the same color:
<br>
<select name="Color_1" onChange="NoDupl(this,document.MForm.Color_2)">
<option selected value=''>Select your first prefered color</option>
<option value='R'>Red</option>
<option value='J'>Yellow</option>
<option value='G'>Green</option>
<option value='B'>Blue</option>
</select>
<select name="Color_2" onChange="NoDupl(this,document.MForm.Color_1)">
<option selected value=''>Select Second Prefered color</option>
<option value='R'>Red</option>
<option value='J'>Yellow</option>
<option value='G'>Green</option>
<option value='B'>Blue</option>
</select>
</form>