首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

怎么将div innerHTML传给servlet

2012-03-21 
如何将div innerHTML传给servletform idform1 methodpost actionpupost divlabel stylefo

如何将div innerHTML传给servlet
<form id="form1" method="post" action="pupost" >
<div>
<label style="font-size:18px;">标题:</label> 
<input id="poTitle" name="poTitle" type="text" style="width:610px; height:25px; font-size:14px;" />
</div>
<div id="poText" contenteditable="true" style="width:610px; height:170px; background-color:#FFFFFF; margin-left:60px; font-size:13px;"></div>
</div>
<input type="submit" class="btn10" onMouseOver="this.style.backgroundPosition='left -40px'" onMouseOut="this.style.backgroundPosition='left top'" value="发 表" />
</form>


如果想把poText的innerHTML传给servlet pupost 应该怎么办?

[解决办法]

HTML code
<html>    <head>        <script>            function mysubmit()            {                var str = document.getElementById("mydiv").innerHTML;                document.getElementById("content").value = str;                document.forms["myform"].submit();            }        </script>    </head>    <body>        在servlet里用request.getParameter("content")获取        <form id="myform" action="你的servlet路径" method="post">            <input type="hidden" name="content" id="content"/>            <div id="mydiv">qwerqwegqwegqweg</div>            <input type="button" onclick="mysubmit()" value="提交"/>        </form>    </body></html> 

热点排行