Form Refresh!

Discussion in 'JavaScript' started by anton-shirikov, Nov 11, 2007.

  1. #1
    Hello!
    I heed a script. It should refresh a form after a user pick a value (so next options list will depend on what value user picked b4).

    Thank you! :)
     
    anton-shirikov, Nov 11, 2007 IP
  2. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
  3. anton-shirikov

    anton-shirikov Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yeah this is how i want this form to work :) this is what i need - www(dot)kroon-oil(dot)com/uk/products/productrecommendation(dot)php

    I never worked with JavaScript b4, so might be hard for me :/ And i need script to take info from database (i am using PHP). Here is full code of that page:
    <?php 
        require($_SERVER["DOCUMENT_ROOT"]."/xenum/config/db_config.php"); 
        $connection = mysql_connect($db_host, $db_user, $db_password); 
    if(!$connection){ 
    die(mysql_error()); 
    } 
    $selectDb = mysql_select_db($db_name, $connection); 
    if(!$selectDb){ 
    die(mysql_error()); 
    } 
    ?> 
    
    <html> 
    <head> 
        <title></title> 
    </head> 
    <body bgcolor="black"> 
        <div align="center"> 
            <table> 
                <tr> 
                    <td><img src="images/image_03.jpg"></td> 
                </tr> 
                <tr> 
                    <td> 
                     
                    <!--Main Table--> 
                        <table border="0" cellspacing="0" cellpadding="0" background="images/image_05.jpg" width="964" height="527"> 
                            <tr> 
                                <td> 
                                    <table border="0" width="100%" height="100%"> 
                                        <form method="post" action="<?php echo $_SERVER[PHP_SELF]; ?>"> 
                                        <tr height="20%"> 
                                            <td width="25%"></td> 
                                            <td width="25%"><font color="#ff6600"><h3>1</h3>Выберите тип автомобиля: </font></td> 
                                            <td width="50%"><br><br><select class="mini" name="cat"> 
                                            <option class="mini" value="">...........................................................................</option> 
                                            <?php 
                                                $query = "SELECT cat FROM cars"; 
                                                $result = mysql_query($query, $connection); 
                                                $i = 0; 
                                                 
                                                while($row = mysql_fetch_assoc($result)) 
                                                { 
                                                    $i++; 
                                                    echo "<option class='mini' value='$i'>".$row['cat']."</option>";
                                                }
    											$cat = $_POST['cat']; 
                                            ?> 
                                            </select> 
                                            </td> 
                                        </tr> 
                                        <tr height="20%"> 
                                            <td width="25%"></td> 
                                            <td width="25%"><font color="#ff6600"><h3>2</h3>Выберите марку автомобиля: </font></td> 
                                            <td width="50%"><br><br><select class="mini" name="make"> 
                                            <option class="mini" value="">...........................................................................</option> 
                                            <?php 
                                                $query = "SELECT make FROM cars WHERE cat = $cat"; 
                                                $result = mysql_query($query, $connection); 
                                                $i = 0; 
                                                 
                                                while($row = mysql_fetch_assoc($result)) 
                                                { 
                                                    $i++; 
                                                    echo "<option class='mini' value='$i'>".$row['make']."</option>";
    											}
    											$make = $_POST['make'];                        
                                            ?> 
                                            </select></td> 
                                        </tr> 
                                        <tr height="20%"> 
                                            <td width="25%"></td> 
                                            <td width="25%"><font color="#ff6600"><h3>3</h3>Выберите модель автомобиля: </font></td> 
                                            <td width="50%"><br><br><select class="mini" name="model"> 
                                            <option class="mini" value="">...........................................................................</option> 
                                            <?php 
                                                $query = "SELECT model FROM cars WHERE make = $make"; 
                                                $result = mysql_query($query, $connection); 
                                                $i = 0; 
                                                 
                                                while($row = mysql_fetch_assoc($result)) 
                                                { 
                                                    $i++; 
                                                    echo "<option class='mini' value='$i'>".$row['model']."</option>";			 
                                                }
    											$model = $_POST['model'];
                                            ?> 
                                            </select></td> 
                                        </tr> 
                                        <tr height="20%"> 
                                            <td width="25%"></td> 
                                            <td width="25%"><font color="#ff6600"><h3>4</h3>Выберите  автомобиля: </font></td> 
                                            <td width="50%"><br><br><select class="mini" name="type"> 
                                            <option class="mini" value="">...........................................................................</option> 
                                            <?php 
                                                $query = "SELECT type FROM cars WHERE model = $model"; 
                                                $result = mysql_query($query, $connection); 
                                                $i = 0; 
                                                
                                                while($row = mysql_fetch_assoc($result)) 
                                                { 
                                                    $i++; 
                                                    echo "<option class='mini' value='$i'>".$row['type']."</option>"; 
                                                }
                                            ?> 
                                            </select></td> 
                                        </tr> 
                                        <tr height="20%"> 
                                            <td width="25%"></td> 
                                            <td width="25%"></td> 
                                            <td width="50%"><input type="submit" value="OK"></td> 
                                        </tr>
    									</form> 
                                    </table> 
                                </td> 
                            </tr> 
                        </table> 
                    <!--End's--> 
                     
                    </td> 
                </tr> 
                <tr> 
                    <td><img src="images/image_06.jpg"></td> 
                </tr> 
            </table> 
        </div> 
    </body> 
    </html>
    PHP:
    So Need to use this JavaScript to work as on that website :/
     
    anton-shirikov, Nov 12, 2007 IP
  4. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
  5. anton-shirikov

    anton-shirikov Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yeah this might work :) but again i never worked with JavaScript, so can anyone show an example how i can use this.
    Thanks
     
    anton-shirikov, Nov 12, 2007 IP
  6. anton-shirikov

    anton-shirikov Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yeah this might work :) but again i never worked with JavaScript, so can anyone show an example how i can use this.
    Thanks
     
    anton-shirikov, Nov 12, 2007 IP
  7. anton-shirikov

    anton-shirikov Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    mmm idk how to install a script inside mine :/ Please help me :/
     
    anton-shirikov, Nov 13, 2007 IP
  8. anton-shirikov

    anton-shirikov Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    well. I now use "get" It all works, but is there way to make an option link. So for example if user press option it will go to link index.php?cat=1
    if there is way, i think that is what i need :)
     
    anton-shirikov, Nov 14, 2007 IP
  9. anton-shirikov

    anton-shirikov Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hmm still i might need JavaScript to make that :/
    So can anyone help to install the JavaScript script?
     
    anton-shirikov, Nov 15, 2007 IP