给你一个例子,考,这个例子废了我3个小时!我这人的原则就是共产主义哦!
<?
//get value of very parameter
$jsfile = "ipobject.js";
$fp = fopen($jsfile,"w+");
fwrite($fp,"");
fclose($fp);
$fp = fopen($jsfile,"a+");fwrite($fp,"var groups=document.ipgedit.sobject.options.length\r\n");fwrite($fp,"var group=new Array(groups)\r\n");
fwrite($fp,"for (i=0; i<groups; i++)\r\n");
fwrite($fp,"group[i]=new Array()\r\n"); $SaveFile = "temp.txt";
$Message = file($SaveFile);
$iCount=0;
$j=0;
while($Message[$iCount])
{
////////////////////////////////////////////////////////
if($Message[$iCount][0]=="&")
{
$Message[$iCount] = str_replace("&","", $Message[$iCount]);
$pieces = explode(" ", $Message[$iCount]);
fwrite($fp,"group[$j][0]=\"$pieces[2]\";\r\n");
fwrite($fp,"group[$j][1]=\"$pieces[3]\";\r\n");
$j++;
}
$iCount++;
}
fwrite($fp,"function showsipaddress(x)\r\n");
fwrite($fp,"{\r\n");
fwrite($fp,"document.ipgedit.sipaddress.value=group[x][0];\r\n");
fwrite($fp,"document.ipgedit.smask.value=group[x][1];\r\n");
fwrite($fp,"}\r\n");
?>
<HTML>
<HEAD>
</HEAD>
<BODY id=all oncontextmenu=self.event.returnValue=false style="FONT-SIZE: 12px"
text=#000000>
<table border=0 cellpadding=0 cellspacing=0 class=p9 width=223> <tr height=21>
<td background=../images/nav1.gif width=7>
<p align=left> </p>
<td align=middle bgcolor=#fcca65 class=spn11
style="BORDER-BOTTOM: #666666 1px solid; BORDER-LEFT: #fcca65 1px solid; BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid"
valign=center width=102>策略管理
<td bgcolor=#666666 width=102>
<table bgcolor=#eeeeee border=0 cellpadding=0 cellspacing=0 class=p9
height=19 width=130>
<tr>
<td align=middle width=100><img height=11
src="../images/nav2.gif"
width=10> 策略配置</td>
</tr>
</table>
<td background=../images/nav3.gif width=17></td>
</tr></table>
<br>
<form name="ipgedit" method="post" action="">
<table border="0" cellpadding="4" cellspacing="1">
<tr>
<td colspan="6" bgcolor="#a9b592"> 方向 内口 ——> 外口</td>
</tr>
<tr>
<td bgcolor="#efefef"> 策略管理</td>
<td colspan="5" bgcolor="#efefef">是否启动日志记录</td>
</tr>
<tr>
<td> </td>
<td>
<div align="right">ACCESS LIST 序号:</div>
</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"sn\" size=\"5\" value = $sn>";
?>
</td>
</tr>
<tr>
<td> </td>
<td>
<div align="right">源地址:</div>
</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"sipaddress\" size=\"18\" value = $sipaddress>";
echo "<input type=\"text\" name=\"smask\" size=\"18\" value = $smask>";
?>
<select name="sobject" onchange = "showsipaddress(this.options.value)">
<?
$SaveFile = "temp.txt";
$Message = file($SaveFile);
$iCount=0;
$j=0;
while($Message[$iCount])
{
////////////////////////////////////////////////////////
if($Message[$iCount][0]=="&")
{
$Message[$iCount] = str_replace("&","", $Message[$iCount]);
$pieces = explode(" ", $Message[$iCount]);
echo"<option value = $j>$pieces[1]</option>";
$j++;
}
$iCount++;
}
?>
</select>
<script src="ipobject.js"> </script>
</td>
</tr>
<tr>
<td> </td>
<td align="right">源端口:</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"sport\" size=\"10\" value = $sport>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">源物理地址:</td>
<td colspan="4">
<input type="text" name="textfield6">
</td>
</tr>
<tr>
<td> </td>
<td>
<div align="right">目的地址:</div>
</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"textfield2\" size=\"18\" value = $dipaddress>";
echo "<input type=\"text\" name=\"textfield3\" size=\"18\" value = $dmask>";
?>
<select name="select">
<option selected>选择目的地址对象</option>
<?
$SaveFile = "temp.txt";
$Message = file($SaveFile);
$iCount=0;
while($Message[$iCount])
{
////////////////////////////////////////////////////////
if($Message[$iCount][0]=="&"||$Message[$iCount][0]=="@")
{
$Message[$iCount] = str_replace("&","", $Message[$iCount]);
$pieces = explode(" ", $Message[$iCount]);
echo"<option value = >$pieces[1]</option>";
$j++;
}
$iCount++;
}
?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td align="right">目的端口:</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"dport\" size=\"10\" value = $dport>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">目的物理地址:</td>
<td colspan="4">
<?
echo " <input type=\"text\" name=\"mac\" value = $mac>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">添加服务:</td>
<td colspan="4">
<select name="select3">
<option selected>添加服务</option>
<?
include ("service.php");
?>
</select>
<select name="select4">
<option selected>添加服务对象</option>
</select>
</td>
</tr>
<tr>
<td> </td>
<td align="right">状态:</td>
<td colspan="4">
<?
echo "<select name=\"state\">";
echo "<option selected>$state</option>";
echo"</select>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">是否通过:</td>
<td colspan="4"> 拒绝 :
<input type="radio" name="radiobutton" value="radiobutton">
通过:
<input type="radio" name="radiobutton" value="radiobutton">
</td>
</tr>
<tr>
<td> </td>
<td align="right">是否日志:</td>
<td colspan="4"> 是:
<input type="radio" name="radiobutton" value="radiobutton">
否:
<input type="radio" name="radiobutton" value="radiobutton">
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="4">
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置">
</td>
</tr>
<tr bgcolor="#efefef">
<td colspan="6"> </td>
</tr>
</table>
</form>
</BODY></HTML>
<?
//get value of very parameter
$jsfile = "ipobject.js";
$fp = fopen($jsfile,"w+");
fwrite($fp,"");
fclose($fp);
$fp = fopen($jsfile,"a+");fwrite($fp,"var groups=document.ipgedit.sobject.options.length\r\n");fwrite($fp,"var group=new Array(groups)\r\n");
fwrite($fp,"for (i=0; i<groups; i++)\r\n");
fwrite($fp,"group[i]=new Array()\r\n"); $SaveFile = "temp.txt";
$Message = file($SaveFile);
$iCount=0;
$j=0;
while($Message[$iCount])
{
////////////////////////////////////////////////////////
if($Message[$iCount][0]=="&")
{
$Message[$iCount] = str_replace("&","", $Message[$iCount]);
$pieces = explode(" ", $Message[$iCount]);
fwrite($fp,"group[$j][0]=\"$pieces[2]\";\r\n");
fwrite($fp,"group[$j][1]=\"$pieces[3]\";\r\n");
$j++;
}
$iCount++;
}
fwrite($fp,"function showsipaddress(x)\r\n");
fwrite($fp,"{\r\n");
fwrite($fp,"document.ipgedit.sipaddress.value=group[x][0];\r\n");
fwrite($fp,"document.ipgedit.smask.value=group[x][1];\r\n");
fwrite($fp,"}\r\n");
?>
<HTML>
<HEAD>
</HEAD>
<BODY id=all oncontextmenu=self.event.returnValue=false style="FONT-SIZE: 12px"
text=#000000>
<table border=0 cellpadding=0 cellspacing=0 class=p9 width=223> <tr height=21>
<td background=../images/nav1.gif width=7>
<p align=left> </p>
<td align=middle bgcolor=#fcca65 class=spn11
style="BORDER-BOTTOM: #666666 1px solid; BORDER-LEFT: #fcca65 1px solid; BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid"
valign=center width=102>策略管理
<td bgcolor=#666666 width=102>
<table bgcolor=#eeeeee border=0 cellpadding=0 cellspacing=0 class=p9
height=19 width=130>
<tr>
<td align=middle width=100><img height=11
src="../images/nav2.gif"
width=10> 策略配置</td>
</tr>
</table>
<td background=../images/nav3.gif width=17></td>
</tr></table>
<br>
<form name="ipgedit" method="post" action="">
<table border="0" cellpadding="4" cellspacing="1">
<tr>
<td colspan="6" bgcolor="#a9b592"> 方向 内口 ——> 外口</td>
</tr>
<tr>
<td bgcolor="#efefef"> 策略管理</td>
<td colspan="5" bgcolor="#efefef">是否启动日志记录</td>
</tr>
<tr>
<td> </td>
<td>
<div align="right">ACCESS LIST 序号:</div>
</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"sn\" size=\"5\" value = $sn>";
?>
</td>
</tr>
<tr>
<td> </td>
<td>
<div align="right">源地址:</div>
</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"sipaddress\" size=\"18\" value = $sipaddress>";
echo "<input type=\"text\" name=\"smask\" size=\"18\" value = $smask>";
?>
<select name="sobject" onchange = "showsipaddress(this.options.value)">
<?
$SaveFile = "temp.txt";
$Message = file($SaveFile);
$iCount=0;
$j=0;
while($Message[$iCount])
{
////////////////////////////////////////////////////////
if($Message[$iCount][0]=="&")
{
$Message[$iCount] = str_replace("&","", $Message[$iCount]);
$pieces = explode(" ", $Message[$iCount]);
echo"<option value = $j>$pieces[1]</option>";
$j++;
}
$iCount++;
}
?>
</select>
<script src="ipobject.js"> </script>
</td>
</tr>
<tr>
<td> </td>
<td align="right">源端口:</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"sport\" size=\"10\" value = $sport>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">源物理地址:</td>
<td colspan="4">
<input type="text" name="textfield6">
</td>
</tr>
<tr>
<td> </td>
<td>
<div align="right">目的地址:</div>
</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"textfield2\" size=\"18\" value = $dipaddress>";
echo "<input type=\"text\" name=\"textfield3\" size=\"18\" value = $dmask>";
?>
<select name="select">
<option selected>选择目的地址对象</option>
<?
$SaveFile = "temp.txt";
$Message = file($SaveFile);
$iCount=0;
while($Message[$iCount])
{
////////////////////////////////////////////////////////
if($Message[$iCount][0]=="&"||$Message[$iCount][0]=="@")
{
$Message[$iCount] = str_replace("&","", $Message[$iCount]);
$pieces = explode(" ", $Message[$iCount]);
echo"<option value = >$pieces[1]</option>";
$j++;
}
$iCount++;
}
?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td align="right">目的端口:</td>
<td colspan="4">
<?
echo "<input type=\"text\" name=\"dport\" size=\"10\" value = $dport>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">目的物理地址:</td>
<td colspan="4">
<?
echo " <input type=\"text\" name=\"mac\" value = $mac>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">添加服务:</td>
<td colspan="4">
<select name="select3">
<option selected>添加服务</option>
<?
include ("service.php");
?>
</select>
<select name="select4">
<option selected>添加服务对象</option>
</select>
</td>
</tr>
<tr>
<td> </td>
<td align="right">状态:</td>
<td colspan="4">
<?
echo "<select name=\"state\">";
echo "<option selected>$state</option>";
echo"</select>";
?>
</td>
</tr>
<tr>
<td> </td>
<td align="right">是否通过:</td>
<td colspan="4"> 拒绝 :
<input type="radio" name="radiobutton" value="radiobutton">
通过:
<input type="radio" name="radiobutton" value="radiobutton">
</td>
</tr>
<tr>
<td> </td>
<td align="right">是否日志:</td>
<td colspan="4"> 是:
<input type="radio" name="radiobutton" value="radiobutton">
否:
<input type="radio" name="radiobutton" value="radiobutton">
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="4">
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置">
</td>
</tr>
<tr bgcolor="#efefef">
<td colspan="6"> </td>
</tr>
</table>
</form>
</BODY></HTML>
$a = array(1,2,3,4);
echo "<script language=JavaScript>";//echo "list=new Array(".$a.");";
echo "list=new Array(".implode(",",$a).");";echo "for(i=0;i<list.length;i++){window.alert(list[i]);}";//此处不能正常显示值
echo "</script>";
?>