Loading ...
Sorry, an error occurred while loading the content.
 

Linked Selects from Database

Expand Messages
  • operationsengineer1@yahoo.com
    hi Manuel, i reviewed your linked select example and saw it in action - it is nice. thanks for doing this. i want to use a database to populate the linked
    Message 1 of 54 , Aug 3, 2005
      hi Manuel,

      i reviewed your linked select example and saw it in
      action - it is nice. thanks for doing this.

      i want to use a database to populate the linked
      selects.

      this is the code i use (adodb abstraction layer) to
      populate a select menu (thanks to your help, of
      course!):

      $options_product=array(''=>'Enter Product Number');
      while (!$rs_product->EOF) {
      $options_product[$rs_product->fields[0]]=$rs_product->fields[1];
      $rs_product->MoveNext();
      }
      reset ($options_product);
      $first_id = key($options_product);

      if i understand correctly, this methodology will work
      fine for populating the continent select box in your
      example.

      the countries select is a bit more tricky. i'll give
      it my best shot and i would appreciate your feedback.

      //set initial value

      $country=array(""=>array(""=>"Select country");

      //populate rest of array

      while (!$rs_continent->EOF){
      $country[$rs_continent->fields[0]]=array(

      while (!$rs_country->EOF){
      [$rs_countries->fields[0]]=$rs_countries->fields[1];
      $rs_countries->move next
      }
      )

      $rs_continent->move next
      }

      does this do the trick? i searched the net and found
      nothing. i spent over an hour working through this
      point. if it doesn't work, any guidance would be
      appreciated.

      ps - i couldn't indent so i used vertical spaces to
      separate the code.


      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com
    • Manuel Lemos
      Hello, ... The matter is that it does not make much sense the original state when the options of a select are changed dynamically with Javascript. The linked
      Message 54 of 54 , Aug 11, 2005
        Hello,

        on 08/11/2005 02:55 PM operationsengineer1@... said the following:
        > again, i hope there isn't something i'm doing wrong
        > that that is causing this minor issue.
        >
        > when i reset the form, everything clears to its
        > original state except the child select which displays
        > the values it had prior to hitting the reset button.
        >
        > the actual selected value may well clear, but the
        > displayed values still display.

        The matter is that it does not make much sense the original state when
        the options of a select are changed dynamically with Javascript. The
        linked select inputs only react to direct changes performed by the user
        of value in the linked input. Using a reset button is not a direct
        change to linked input.

        You may want to try a workaround of calling the change() function of the
        linked input Javascript object in the ONRESET attribute of the form.


        > i also noticed that when i turn javascript off (using
        > firefox), the reset button doesn't work at all.

        With Javascript off, nothing is supposed to work because the linked
        selects rely on being called the change event of the linked input, which
        obviously never happens.

        --

        Regards,
        Manuel Lemos

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/

        PHP Reviews - Reviews of PHP books and other products
        http://www.phpclasses.org/reviews/

        Metastorage - Data object relational mapping layer generator
        http://www.meta-language.net/metastorage.html
      Your message has been successfully submitted and would be delivered to recipients shortly.