- 论坛徽章:
- 0
|
我发几个办法给你
- <SCRIPT>
- function test8(){
- var value1=document.getElementById("text7").value;
- document.getElementById("text8").value=value1;
-
- }
- </SCRIPT>
- <input type="text" id="text7" name ="text7" value=""/>
- <input type="text" id="text8" name ="text7" value=""/>
- <input type="button" name="button8" value="button8" onclick="test8()">
复制代码
- <?php
- $i="这样就可以";
- ?>
- <script language=JScript>
- var i="<?echo $i?>"
- alert(i);
- </script>
复制代码
- <?php
- if($submitubb)
- {
- //printf("<br>转换后的HTML: %s",$htmlstr);
- printf("<br>转换前的UBB: %s",$ubbstr);
- }
- else
- {
- ?>
- <html>
- <head>
- <script language="javascript" src="hent.js"></script>
- <head>
- <body>
- <form action=jsubb.php method=post>
- <textarea name=ubbstr id=ubbcode></textarea><br>
- <!--
- <input type=text id=htmlcode name=htmlstr>
- -->
- <!--
- 请注意这一句 我需要解决的是在这步里通过客户端的JS脚本把UBB字符串转为HTML,然后在把值传给PHP,因为HTML和JS变量没有具体的联系,传给JS后,JS有没有办法再传回HTML,如果不行在提交表单时转换好,传给PHP也是一样的,有没有办法做到。
- 我需要的结果是:
- 在HTML表单输入:[b]粗体[/b][email]email@email.com[/email][size=5]5号标题字[/size]
- 在PHP脚本输出:<b>粗体</b><a herf="mailto:email@email.com">email@email.com</a><font size=5>5号标题字</font>
- -->
- <script language="javascript">
- function ubb2html()
- {
- var str=document.getElementById("ubbcode").value;
- document.getElementById("ubbcode").value=JsUBB(str);
- }
- </script>
- <input type=submit name=submitubb value="提交UBB字串" onclick="ubb2html()">
- </form>
- </body>
- </html>
- <?php
- }
- ?>
复制代码
最后一个是自己做的
你可能需要一个安全字符函数
- <?php
- function rteSafe($strText) {
- //returns safe code for preloading in the RTE
- $tmpString = $strText;
-
- //convert all types of single quotes
- $tmpString = str_replace(chr(145), chr(39), $tmpString);
- $tmpString = str_replace(chr(146), chr(39), $tmpString);
- $tmpString = str_replace("'", "'", $tmpString);
-
- //convert all types of double quotes
- $tmpString = str_replace(chr(147), chr(34), $tmpString);
- $tmpString = str_replace(chr(148), chr(34), $tmpString);
- // $tmpString = str_replace("\"", "\"", $tmpString);
-
- //replace carriage returns & line feeds
- $tmpString = str_replace(chr(10), " ", $tmpString);
- $tmpString = str_replace(chr(13), " ", $tmpString);
-
- return $tmpString;
- }
- ?>
复制代码 |
|