Results 1 to 3 of 3

Thread: I need an example

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    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.

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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..

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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
  •  



Click Here to Expand Forum to Full Width