|
|
楼主 |
发表于 2012-6-4 15:22:06
|
显示全部楼层
Extend .NET text string processiong
本帖最后由 demo 于 2012-6-5 07:23 编辑
As you can see, I have some text processing in PHP to make sure just get the value of the variable "name". This is because of variable created by .NET program and we can hardly remove it.
We can use Javascript to standarize it before submit and that make the program more friendly.
- <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Logwrite.aspx.vb" Inherits="_Default" %>
- <!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" >
- <head runat="server">
- <title>Test - </title>
- </head>
- <body text="#000099" vlink="#660099" onload="javascript: myfunc()">
- <form id="form1" runat="server">
- <div id="Identity">
- Welcome! ---
- </div>
- </form>
- <form id="frm" action="http://test2/jzx/answer.php" method=get>
- <input type=hiden name="name" value='<asp:Label ID="str_LogID" runat="server" />' >
- <input type="Submit" ID="sub1" Value="Submit">
- </form>
- <script type="text/javascript">
- function myfunc () {
- //var mym = document.getElementById("name");
- //var msg = mym.value.replace("<span id="str_LogID">","").replace("</span>","");
- document.getElementById("name").value = document.getElementById("name").value.replace("<span id="str_LogID">","").replace("</span>","");
- //alert("This is from:" + mym + ". and that is " + msg);
- document.forms["frm"].submit();
- //var frm = document.getElementById("name");
- //frm.submit();
- }
- //window.onload = myfunc;
- </script>
- </body>
- </html>
复制代码
and the PHP code can back to a short one:
- <?php
- $myname = $_GET["name"];
- echo "<html><head><title>Response</title></head>";
- echo "<body>Welcome $myname !";
- echo "</body></html>";
- ?>
复制代码
|
|