填写表单时只更新表单不重新加载整个页面

时间:2014-04-11 13:31:04

标签: php mysql forms

我有以下表格:

    <form action="" method="get" target="_self">
    <select name="Category" class="dropmenu" id="Category"onchange="this.form.submit()">
                     <option value="">Any</option>
                     <option value="Keyboard"<?php if ($_GET['Category']=="Keyboard") {echo "selected='selected'"; } ?>>Keyboard</option>
                     <option value="Piano"<?php if ($_GET['Category']=="Piano") {echo "selected='selected'"; } ?>>Piano</option>
                   </select>
   <select name='Manufacturer' class="dropmenu" onChange="this.form.submit()" >

             <?php  
                  echo '<option value="">Any</option>';
                 while ($row = mysql_fetch_array($RS_Search1)) {
        $selected = $_GET['Manufacturer'] == $row['Manufacturer'] ? 'selected' : '';
        echo '<option '.$selected.'>' . $row['Manufacturer'] . '</option>';
    } ?>        </select>
    <select name="Color" class="dropmenu" onChange="this.form.submit()">
                     <?php  
                  echo '<option value="">Any</option>';
                 while ($Color = mysql_fetch_array($RS_Search2)) {
        $selected2 = $_GET['Color'] == $Color['Color'] ? 'selected' : '';
        echo '<option '.$selected2.'>' . $Color['Color'] . '</option>';
    } ?>  </form>

提交第二个表单

<form action="search2.php" method="get">                   </select><input name="Category" type="hidden" value="<?php echo $_GET['Category']; ?>">
    <input name="Manufacturer" type="hidden" value="<?php echo $_GET['Manufacturer']; ?>">
    <input name="Color" type="hidden" value="<?php echo $_GET['Color']; ?>">
                   <select name="price" class="dropmenu">
                     <?php  
                  echo '<option value="">Any</option>';
                 while ($Price = mysql_fetch_array($RS_Price)) {
        $selected3 = $_GET['price_range'] == $Price['price_range'] ? 'selected' : '';
            echo '<option '.$selected3.'>' . $Price['price_range']. '</option>';
    } ?>


      </select><input name="Search2" type="submit"  id="Search2" value="Submit">



</form>

如您所见,在选择第一个值之后,将从db中提取选项值。表单上的内容是重新加载整个页面。有没有办法重新加载表单而不是重新加载整个页面。我需要保留在更改选项值时提交的值,以便能够填写下一个下拉菜单。 欢迎任何帮助。

0 个答案:

没有答案