No Duplicates Script

wxdqz

New Member
I'm trying to modify the No Duplicates script so that iterms not selected from the second dropdown box automatically populate a third dropdown, but am not having much luck. Any ideas?

<!--

Script Name: No Duplicates

Website URL: <!-- m --><a class="postlink" href="http://javascript.internet.com/forms/no-duplicates.html">http://javascript.internet.com/forms/no-duplicates.html</a><!-- m -->

Description: Prevents you from selecting the same choice when choosing from two different pulldown menus.

-->


<!-- TWO STEPS TO INSTALL NO DUPLICATES:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Denis Dijon (<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->) -->
<!-- Web Site: <!-- m --><a class="postlink" href="http://213.177.134.20">http://213.177.134.20</a><!-- m --> -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! <!-- m --><a class="postlink" href="http://javascript.internet.com">http://javascript.internet.com</a><!-- m --> -->

<!-- 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>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<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='http://www.webdeveloper.com/forum/archive/index.php/R'>Red</option>
<option value='http://www.webdeveloper.com/forum/archive/index.php/J'>Yellow</option>
<option value='http://www.webdeveloper.com/forum/archive/index.php/G'>Green</option>
<option value='http://www.webdeveloper.com/forum/archive/index.php/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='http://www.webdeveloper.com/forum/archive/index.php/R'>Red</option>
<option value='http://www.webdeveloper.com/forum/archive/index.php/J'>Yellow</option>
<option value='http://www.webdeveloper.com/forum/archive/index.php/G'>Green</option>
<option value='http://www.webdeveloper.com/forum/archive/index.php/B'>Blue</option>
</select>
</form>

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href=http://www.webdeveloper.com/forum/archive/index.php/"http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 2.34 KB -->
 
Top