链接选择菜单,如何链接"使用 href 链接提交?



我一直在使用数据库SQL进行PHP的链式选择菜单(因为以后我需要为客户端开发更新可能性)。

但是,链式菜单(在2个级别上)效果很好,

问题是我不知道如何将按钮链接到另一个页面。。。并且根据选择的"物品",如果有人可以给我一些高云,我真的很感激。

这是jQuery部分,现在直接显示该值:,而不是为另一页链接到另一页。

$("#result").html('Your choice: '+result);

这是我一直关注的教程:

http://www.yourinspirationweb.com/en/how-to-to-create-chasine-chasine-select-with-php-and-jquery/

非常感谢!

fir,如果您需要将用户发送到其他页面,具体取决于选择,则应创建一个字段"目标",可以在数据库中保存URL:

CREATE TABLE `type` (
`id_type` int(4) unsigned NOT NULL auto_increment,
`id_cat` int(4) unsigned NOT NULL,
`name` varchar(40) NOT NULL,
`destination` varchar(40) NOT NULL,
PRIMARY KEY  (`id_type`)
) ENGINE=MyISAM AUTO_INCREMENT=15 ;

然后从表中获取URL并将其放在选项值

   public function ShowCategory()
    {
        $sql = "SELECT * FROM category";
        $res = mysql_query($sql,$this->conn);
        $category = '<option value="0">choose...</option>';
        while($row = mysql_fetch_array($res))
        {
            $category .= '<option value="' . $row['destination'] . '">' . $row['name'] . '</option>';
        }
        return $category;
    }

和Finaly使jQuery重定向到提交的页面

$("#select_form").submit(function( event ) {
  var the_url = $("#type").val();
  window.location = the_url;
  event.preventDefault();
});

希望有帮助。

最新更新