doutao6653 2016-04-19 17:55
浏览 28

php返回表后移动一个值

I have a title on my page. It is inside a div tag. When the page is displayed it is simple and says "Net Control Manager". After the user makes a selection a PHP program runs MySQL and returns a table. It also returns a value that I want to put into the title. So that it would say "Net Control Manager: PCARG" for example.

The problem is I'm not sure how to put that extra piece into the div. I write the value to another div with an echo from the php "echo $value" which is returned correctly. Then in an onload in the body tag I use a function to retrieve the new div (newport), and add it to the title div. But since the onload happens first all I get is "undefined".

How do I make it wait for the new div to be written with the new data? Or is there another method I don't know about.

  • 写回答

1条回答 默认 最新

  • drg14799 2016-04-19 18:07
    关注

    If I read this correctly, you're just looking to pick up some text and append it to another div's text?

    You could do something like this -- making sure it's at the bottom of your HTML before the closing </body> tag.

    <script type="text/javascript">
      $(document).ready(function () {
        var title = $('#title'); // Or whatever your div id or class name is.
        var newport = $('#newport'); // Or whatever your div id or class name is.
    
        // This will append the text from your `newport` onto your `title` div. 
        title.text(title.text() + ' ' + newport.text())
      });
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题