Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 1st, 2005, 05:19 AM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 3 Drop Down box w/ db values & dependent choices

Hi,

i am looking for a ASP VB script for the following problem:

i have 3 databases with categories. A form on my website should show 3 drop down menus. The user selects category 1, and the value of category 2 drop down box gets updated with new values. same happens after the user select cat 2 box - the 3rd box gets updated with new values.

can you provide me with a sample script, two boxes in the sample would be enough. would just need VB script.

Thanks, Mark

  #2 (permalink)  
Old March 2nd, 2005, 03:32 PM
Authorized User
 
Join Date: Aug 2003
Location: Jakarta, DKI Jakarta, Indonesia.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sherief Send a message via Yahoo to sherief
Default

Hi smarks,

I used javascript to create this, here is some simple example:

<script language="javascript">
<!--
    function chooseVehicle() {
        chooseMerk = document.frmlist.optmerk.options[document.frmlist.optmerk.options.selectedIndex].value;
        switch (chooseMerk) {
            case '#' : isi = 'Pilih Model';
            isival = '#';break;

<-- put your ASP code here -->

            case '1' : isi = 'Pilih Model,A3,A4,A6,Allroad Quatro,TT';
            isival = '#,1,2,3,4,5';break;

            case '2' : isi = 'Pilih Model,3 Series,5 Series,7 Series,X Series,Z3';
            isival = '#,6,7,8,9,10';break;

            case '3' : isi = 'Pilih Model,Blazer,New Blazer,Tavera LT,Zafira';
            isival = '#,11,12,13,14';break;

            case '4' : isi = 'Pilih Model,Ceria,Espass,Taft,Taruna,YRV,Zebra';
            isival = '#,15,16,17,18,19,20';break;

            case '5' : isi = 'Pilih Model,Lanos,Legenza,Matiz,Nubira,Tacuma';
            isival = '#,21,22,23,24,25';break;

            case '6' : isi = 'Pilih Model,Escape,Lynx,Ranger';
            isival = '#,27,28,29';break;

            case '7' : isi = 'Pilih Model,City,Civic,New Accord,New CR-V,Stream';
            isival = '#,30,31,33,35,36';break;

            case '8' : isi = 'Pilih Model,Accent,Atoz,Coupe,Ef Sonata,Grace,Grandeur,Matrix,Santa Fe,Trajet';
            isival = '#,37,38,39,40,41,42,43,44,45';break;

            case '9' : isi = 'Pilih Model,New Panther';
            isival = '#,46';break;

            case '10' : isi = 'Pilih Model,S Type,X Type';
            isival = '#,48,49';break;

            case '11' : isi = 'Pilih Model,Cherokee,Chrysler,Grand Cherokee';
            isival = '#,50,51,52';break;

            case '12' : isi = 'Pilih Model,Carens,Carnival,Carnival II,K 2700 II,Magentiz,New Carens,New Carens II,New Visto,Pregio,RIO,Sedona,Shuma,Spectra Wing,Sportage,Visto';
            isival = '#,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68';b reak;

            case '14' : isi = 'Pilih Model,E,Tribute';
            isival = '#,75,76';break;

            case '15' : isi = 'Pilih Model,A Series,C Series,E Series,M Series,S Series';
            isival = '#,77,78,79,80,81';break;

            case '16' : isi = 'Pilih Model,Galant,Kuda,L200,L300,New Lancer,T 120 SS';
            isival = '#,82,84,85,86,87,88';break;

            case '17' : isi = 'Pilih Model,Infinity,Sentra,Terrano,X-Trail,Cefiro';
            isival = '#,90,93,95,96,139';break;

            case '18' : isi = 'Pilih Model,Blazer,Zafira';
            isival = '#,97,141';break;

            case '19' : isi = 'Pilih Model,206,306,307,406';
            isival = '#,98,99,100,101';break;

            case '20' : isi = 'Pilih Model,Clio,Kangoo,Scenic';
            isival = '#,103,104,105';break;

            case '21' : isi = 'Pilih Model,Forester,Impreza,New Forester';
            isival = '#,106,107,108';break;

            case '22' : isi = 'Pilih Model,New Musso,Rexton';
            isival = '#,111,112';break;

            case '23' : isi = 'Pilih Model,Aerio,Baleno,Karimun,Katana,New Escudo,ST 100,ST 150';
            isival = '#,113,114,115,116,117,118,119';break;

            case '24' : isi = 'Pilih Model,S515i';
            isival = '#,120';break;

            case '25' : isi = 'Pilih Model,Crown,New Camry 2002,New Corolla Altis,New Kijang,New Soluna,Previa';
            isival = '#,121,123,124,125,126,127';break;

            case '26' : isi = 'Pilih Model,S 80,S 40,V 70';
            isival = '#,130,132,133';break;

            case '27' : isi = 'Pilih Model,Caravelle,Golf,New Beetle,Passat,Polo';
            isival = '#,135,136,137,138,143';break;

        }
        isis = isi.split(',');
        isivals = isival.split(',');
        pjgisi = isis.length;
        pjg = document.frmlist.optmodel.options.length;
        for (i=pjg-1;i>=0;i--) { document.frmlist.optmodel.options[i+1] = null; }
         for (i=0;i<pjgisi;i++) document.frmlist.optmodel.options[i] = new Option(isis[i],isivals[i]);
          document.frmlist.optmodel.options[0].selected = true;
    }
//-->
</script>

<form name="frmlist" action="[SOMEFILES]" method="post">
<table width="615" border="0" cellspacing="1" cellpadding="0" align="center">

          <tr>
        <td>
        <select name="optmerk" onchange="javascript:chooseVehicle();" style="width: 160px">

          <option value="#">Please choose one</option>

<-- put your ASP code -->

          <option value="1">Audi</option>


          <option value="2">BMW</option>


          <option value="3">Chevrolet</option>



          <option value="4">Daihatsu</option>


          <option value="5">Daewoo</option>


          <option value="6">Ford</option>


          <option value="7">Honda</option>


          <option value="8">Hyundai</option>


          <option value="9">Isuzu</option>



          <option value="10">Jaguar</option>


          <option value="11">Jeep Chrysler</option>


          <option value="12">KIA</option>


          <option value="14">Mazda</option>


          <option value="15">Mercedez-Benz</option>


          <option value="16">Mitsubishi</option>



          <option value="17">Nissan</option>


          <option value="18">Opel</option>


          <option value="19">Peugeot</option>


          <option value="20">Renault</option>


          <option value="21">Subaru</option>


          <option value="22">Ssangyong</option>



          <option value="23">Suzuki</option>


          <option value="24">Timor</option>


          <option value="25">Toyota</option>


          <option value="26">Volvo</option>


          <option value="27">VW</option>

        </select>

         </td>
    </tr>
    <tr>
        <td><select name="optmodel" style="width: 160px">
            <option value="#">Pilih Model</option>
        </select>
              <input type="image" name="btnsubmit" src="images/bt_tampil.gif" width="80" height="16">
      </td>

    </tr>
</table>
</form>

is this enough?

Regards,
Sherief C. Mursyidi


Similar Threads
Thread Thread Starter Forum Replies Last Post
dependent drop downs p2pMember ASP.NET 1.0 and 1.1 Professional 0 July 19th, 2006 05:25 AM
insert values into a MySQL DB from a drop down men crmpicco Classic ASP Basics 26 January 24th, 2005 08:10 AM
Retrive values to Drop down list from DB when Back choudhmh Pro VB.NET 2002/2003 0 January 12th, 2005 10:44 AM
Drop Down/Combo box/List in a Form from DB mazimi Classic ASP Basics 2 October 1st, 2004 10:43 AM
Two drop down dependent list boxes and a Button tcasp Classic ASP Basics 0 August 5th, 2003 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.