|
-
Oct 28th, 2000, 11:33 AM
#1
Thread Starter
Hyperactive Member
Does anyone have a good example of two dropdown boxes that will update their respective views from rows in a database? What I need to do is have the selected value of dropdownbox1 with values a,b,c,...(from column "letters")and dropdownbox2 with values 1,2,3...(from column "numbers") show "b" in dropdown1 and "2" in dropdown2. These values are from the same row in database. I also want this to happen on the fly - like with a "refresh" in real VB instead of a reload page button. Please - I know this has been done. Please share an example.
-
Oct 28th, 2000, 11:12 PM
#2
Frenzied Member
You can do it two ways:
Create dynamic client side code that is written to the html stream. This puts your data on the client side in an array and allows it to have access to it to change the contents of one select based on the click of another.
or
You can specify the same value for both SELECT options so that the ones you want to change match with one another, then on the click event of one, loop through the options collection of the other and look for the same value, when you find it, set the selected property to true.
If you need actual code I can probably drum something up..
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Oct 28th, 2000, 11:32 PM
#3
Frenzied Member
Code:
<HTML>
<HEAD>
<TITLE>test.htm</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function selTest_onchange(){
var intloop;
var myvalue = selTest.options(selTest.selectedIndex).value;
for(intloop=1; intloop < selTest2.options.length; intloop++){
if (selTest2.options(intloop).value == myvalue) selTest2.options(intloop).selected=true;
}
}
-->
</SCRIPT>
</HEAD>
<BODY>
<SELECT onchange="selTest_onchange()" ID="selTest" NAME="selTest">
<OPTION VALUE="1">One
<OPTION VALUE="2">Two
<OPTION VALUE="3">Three
<OPTION VALUE="4">Four
<OPTION VALUE="5">Five
</SELECT>
<SELECT ID="selTest2" NAME="selTest2">
<OPTION VALUE="1">A
<OPTION VALUE="2">B
<OPTION VALUE="3">C
<OPTION VALUE="4">D
<OPTION VALUE="5">E
</SELECT>
</BODY>
</HTML>
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|