how can i show specific data based on currently selected option in a dropdown list?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Monomita Har
    New Member
    • Jan 2013
    • 21

    how can i show specific data based on currently selected option in a dropdown list?

    little background: currently putting together a website that is selling products, many of which come in various sizes, with respectively different prices. I have the database set up to handle all of this.

    However, my issue is thus - how can I go about dynamically changing the product type from dropdown on the product's page, based on the user selecting, display related product from this category on the webpage.

    My current code:
    Code:
    <?php 
    include('connect-db.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form name="product" method="post" action="">
    <table align="center" width="10%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>Shoplist</td>
    <td>
    <select name="shoplist">
    <?php 
    
    $sql = mysql_query("SELECT art_name FROM category");
    
    while ($row = mysql_fetch_array($sql)){
    
    ?>
    <option value="shoplist1"><?php echo $row['art_name']; ?></option>
    
    <?php
    // close while loop 
    }
    ?>
    </select>
    </td>
    <td><input name="go" type="button" value="Go" /></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You have a number of options, e.g.
    1. use a submit button which will submit the form and display the results based on the category selected.
    2. use Ajax to get the results without reloading the page
    3. use an iframe

    I'd suggest number 2 and allow for number 1 where JavaScript is not enabled.

    Comment

    • Monomita Har
      New Member
      • Jan 2013
      • 21

      #3
      dear acoder,

      Please help me regarding this issue.I have one dropdown list with one button.When user select one among them the web page will show the image from mysql database.

      Can you please show me one example if I add one "GO" button and use iframe to show the result on that page? I am very new in this.Thanx in advance!
      Last edited by acoder; Mar 20 '13, 10:53 PM.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        He said to use AJAX. Did you read about it to find out how to use it?

        Comment

        • Monomita Har
          New Member
          • Jan 2013
          • 21

          #5
          Yeah I read it and also tried to find out the problem but cant be able.That's why I request you to explain a little bit.Thanks for any help.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            What did you try? Please post your attempt.

            Comment

            Working...