Drop down box onchange in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • badvoc
    New Member
    • Sep 2007
    • 44

    Drop down box onchange in php

    Sorry about the title wasn't sure how to describe my issue in short form.

    My problem is this.

    I have a dropdown box that is populated from a mySQL database. The reason for this is there are a significant number of options available and much easier to do than code all the options individually.

    When the user clicks an option in the drop down box I want the details of some text boxes to change according to the corresponding data in the database to the option the user has clicked.

    Hope that makes sense so far.

    I am using PHP and mySQL. I understand that Javascript is the way to go, unfortunatly I have not done any other than a few basic tutorials today. I will add the code I have for popultaing the drop down.

    [PHP]
    <form name="makeorder " action="" method="post">
    <label>Select material: </label>
    <select id="material" name="material" >
    <?php
    $sql = "SELECT * FROM upload";
    $result = mysql_query($sq l, $db);

    echo '<option value="">Select </option>';

    while ($row = mysql_fetch_ass oc($result))
    {
    $mat = $row['mat'];
    echo "<option value='$mat'>$m at</option>";
    }
    echo '</select>';
    ?>

    </form>
    [/PHP]

    So if the user clicks option 5 then the page will reload and the details relating to that item will be displyed somewhere on the page.

    Many thanks in advance

    Badvoc
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You almost have the same problem as THIS THREAD . Except you want to fill a textbox instead of generating option statements.

    Have a look at that thread and the proposed tutorial on Ajax chained select. After that come back here to discuss any particular problems you have with your code.

    Ronald

    Comment

    • badvoc
      New Member
      • Sep 2007
      • 44

      #3
      Thanks I'll have a look and come back to you.

      I am only looking for pointers and advice not answers so thank you for directing me to help rather than showing the answers. I have used this forum before and it's always my first point of call after google that is.

      Cheers
      Last edited by badvoc; Apr 3 '08, 07:33 PM. Reason: Nothing showing

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        As long as you feel helped or pointed in the right direction. See you then.

        Ronald

        Comment

        • badvoc
          New Member
          • Sep 2007
          • 44

          #5
          [font=Arial]Cheers Ronald. I was helping a friend with a project he is doing for his degree and we sort of sorted it but went with a different method that was easier for him to understand and implement into his project.[/font]


          Many thanks

          Comment

          Working...