我想在java脚本中调用后台的数据绑定,不知道该怎么做?
例如用java写的滚动文本框,我想在后台从数据库中取出数据,再显示出来,行吗?
<script language=javascript>document.write ("<marquee scrollamount='1' scrolldelay='1' direction= 'UP' width='135' id='helpor_net' height='130' onmouseover='helpor_net.stop()' onmouseout='helpor_net.start()' Author:redriver; For more,visit:www.helpor.net>")
document.write ("<p ><a href='yewugonggao/gonggaolancontent.aspx?id=1' target='_blank'><font color='#ffffff'>公告.....</font></a> ")document.write ("</marquee> ")
</script>
将公告的内容从数据库中取出并显示,大家帮帮我!

解决方案 »

  1.   

    在后台把数据库取出字符串赋值给 marqueeStrvar strList = "<marquee>"+<%= marqueeStr%>+"</marquee>";document.write(strList );
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="gb2312" lang="gb2312">
    <head>
    <title> New Document </title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="title" content="" />
    <meta name="author" content="活靶子,Huobazi,www.AspxBoy.com" />
    <meta name="subject" content="" />
    <meta name="language" content="gb2312" />
    <meta name="keywords" content="" />
    <meta name="Copyright" content="www.AspxBoy.com" />
    <meta name="robots" content="all" />
    <script language="c#" runat="server">
    protected string GetMyString()
    {
    //你可以载这里从数据库取出你要显示的东西,赋给str;
    string str = "aaaaaaaaaaaaaaaaaaaaaaa";
    return str;
    }
    </script>
    </head>
    <body>
    <script>
    var strList = "<marquee><%= GetMyString() %></marquee>";document.write(strList);
    </script>
    </body>
    </html>