Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array question

Status
Not open for further replies.

jduawa

MIS
Jun 11, 2002
73
US
i am using coldfusion and javascript and this is what i want to do...I have the results from a query loaded into the number of arrays that they are in an initial query...so i have 1 query that returns 4 records...therefore the javascript creates 4 arrays and populates them with the results of a second query...i need these results to show up in dropdown boxes and these dropdown boxes can have duplicate records...so one dropdown may have the numbers
1
10
12A

the second dropdown
10
12A

if the user picks 10 from the first drop down i want to remove that choice from the second dropdown...if they then go back to the second dropdown and pick 12a i want to remove that from the first dropdown...kind of stuck...seems complicated...
 
Have you tried using WDDX objects from coldfusion?

Once you run the query and create the object as a Javascript array you can use the Wddx functions provided for Javascript to get the contents for the dropdowns.

As far as getting rid of one option in one dropdown when you select the same option on the the other dropdown It'll be easier (and maybe some other solution arises) if you explain a little bit more in detail the reason why you need this to happen.
It seems to me that it'll be easier to warn the users that the selections can't be the same instead of not showing the value selected in the other dropdown.

grtfercho çB^]\..
"Imagination is more important than Knowledge" A. Einstein
 
the reason being is that certain things are being assigned to certain locations.
Not all of these dropdowns are going to be alike...
if the user assigns one thing to one lcoation that location should not be available to assign another thing to...
my other thinking on this was to just loop through the selections when they submit and look for duplicates.
 
See if this will help you out or at least get you started.
It was based on the examples you gave and I think does what you were asking.


<HTML>
<HEAD>

<script language=&quot;JavaScript&quot;>

function updateSelect()
{
if (document.form1.select1.options[document.form1.select1.selectedIndex].text == &quot;1&quot;)
{

document.form1.select2.options[0] = null;
document.form1.select2.options[1] = null;
document.form1.select2.options[2] = null;


var mySelect = document.form1.select2
var option1 = new Option(&quot;10&quot;, 0);
var option2 = new Option(&quot;12A&quot;, 1);
mySelect.options[0] = option1;
mySelect.options[1] = option2;

}

if (document.form1.select1.options [document.form1.select1.selectedIndex].text == &quot;10&quot;)
{

document.form1.select2.options[0] = null;
document.form1.select2.options[1] = null;
document.form1.select2.options[2] = null;


var mySelect = document.form1.select2
var option1 = new Option(&quot;1&quot;, 0);
var option2 = new Option(&quot;12A&quot;, 1);
mySelect.options[0] = option1;
mySelect.options[1] = option2;

}
if (document.form1.select1.options[document.form1.select1.selectedIndex].text == &quot;12A&quot;)
{

document.form1.select2.options[0] = null;
document.form1.select2.options[1] = null;
document.form1.select2.options[2] = null;


var mySelect = document.form1.select2
var option1 = new Option(&quot;1&quot;, 0);
var option2 = new Option(&quot;10&quot;, 1);
mySelect.options[0] = option1;
mySelect.options[1] = option2;

}
}


</script>
</HEAD>

<body onload=&quot;return updateSelect()&quot;;>

<form name=form1>
<select name=select1 size=1 onchange=&quot;return updateSelect()&quot;;>
<option value=0 selected>1
<option value=1>10
<option value=2>12A
</select>

<select name=select2 size=1>
<option value=0>1
<option value=1>10
<option value=2>12A
</select>
</form>
</body>
</HTML>

Best of Luck..

Brian
 
that is the idea correct, however, my dilema is that the values are being pulled form a query and not all the selct box lengths are the same soze...thanks for the assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top