dpauxqt1281 2015-03-03 11:57
浏览 78
已采纳

将HTML输入到包含的索引页面

I am trying to improve an old website which has been created by having one index.php

Which is behaving like a parent to several sub sites which then insert their specific contents into the parent using javascript (getElement, add all sorts of content and then appendChild).

This results in a huge code to just create a little form, which can be done far neater with HTML.

Thus my question;

how can I input HTML content into a parent file's elements without creating these contents all with javascript?

I am looking for a solution like:

<?php
include_once('index.php');
?>
<ul id="nav">
    <li class="navi"><a href="processlogout.php">Log uit</a></li>
</ul>
<script>
somehow insert newly created unsorted list "nav" into the included index.php
</script>

I hope I have formulated my question clearly and am looking forward to your answers!

  • 写回答

2条回答 默认 最新

  • dongzi5673 2015-03-09 16:27
    关注

    I have found what I was looking for, it was innerHTML
    This way I can simply type an HTML code inside javascript which is then inputted into the included php as I wanted.
    Example;

    document.getElementById('databox').innerHTML = 
    '<div class = "selectform">' +
        '<form id="login" method="post" action="requestklant.php">' +
            '<select name="klantdropdown"></select>' +
            '<button type="submit">Opvragen</button>'+ 
      '</form>' +
    '</div>';
    

    Thank you for your suggestions and effort, though.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?