douzhuiqing1151 2016-03-17 19:08
浏览 111
已采纳

根据一个div到第二个div的结果显示页面内容[关闭]

I have a question.

I have two divs next to each other. In div1 I have created a dropdown menu (10 options available) with php which allows me to open another page; based on what the user chooses.

My question is: instead of opening another page could I display the content of that page inside the second div, aka div2?

If yes, how do you do it?

More details about the issue: practically inside the drop-down menu are 10 options available. so if you choose option 1 it opens page 1, if 2 it opens page 2 etc... so total 10 options linking to 10 different pages. My question is: instead of opening 10 pages separately how can I display the results inside a div next to the drop-down menu :-)

something like loading content/pages dynamically (inside the div) without having to leave the page,

I thank you in advance.

  • 写回答

3条回答 默认 最新

  • dongsechuan0535 2016-03-17 19:24
    关注
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">
    function change_page(page) 
    {   
        if(page!='')
        {
            $.ajax(
            {
                url : page,
                type : "post",
                success : function(data)
                {
                    console.log(data);
                    $("#div_page").html(data);
                }
            })
        }
    }
    </script>
    
    <select id="sel_page" onchange="change_page(this.value)">
        <option value="">Choose page</option>
        <option value="callback.html">Page 1</option>
        <option value="page2.html">Page 2</option>
        <option value="page3.html">Page 3</option>
    </select>
    
    <div id="div_page"></div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 改进Yolov8时添加的注意力模块在task.py里检测不到
  • ¥50 高维数据处理方法求指导
  • ¥100 数字取证课程 关于FAT文件系统的操作
  • ¥15 如何使用js实现打印时每页设置统一的标题
  • ¥15 安装TIA PortalV15.1报错
  • ¥15 能把水桶搬到饮水机的机械设计
  • ¥15 Android Studio中如何把H5逻辑放在Assets 文件夹中以实现将h5代码打包为apk
  • ¥15 使用小程序wx.createWebAudioContext()开发节拍器
  • ¥15 关于#爬虫#的问题:请问HMDB代谢物爬虫的那个工具可以提供一下吗
  • ¥15 vue3+electron打包获取本地视频属性,文件夹里面有ffprobe.exe 文件还会报错这是什么原因呢?