嗨,我有一个包含许多字段的 php 表单,现在我尝试编写将所有这些值存储到数组中的代码,并将它们存储在 javascript 中的 cookie 中。代码如下:
<script type="text/javascript">
function setDate()
{
var today = new Date();
var month = today.getMonth() + 1;
var day = today.getDate();
var year = today.getFullYear();
document.forms['form1'].elements['date'].value= month + "/" + day + "/" + year;
}
function add_newoption(optionname)
{
document.getElementById(optionname).InnerHTML = "";
}
var win = null;
function optionWindow(mypage,myname,w,h){
LeftPosition = (screen.width) ? (screen.width-w)/2: 0;
TopPosition = (screen.height) ? (screen.height-h)/2: 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;
win = window.open(mypage,myname,settings);
win.focus();
}
function setAction(act)
{
document.forms['form1'].action = act;
document.forms['form1'].submit();
}
</script>
表格的代码如下:
<body onLoad="setDate();">
<br/>
<center>
<fieldset class="style1" style="width:800px; background-color:#FFFFFF">
<h4 align="center"> Designer Form </h4>
<form id="form1" name="form1" method="post" >
<table width="700" border="0" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF" style="text-align:left; padding: 25px 0px 25px 0px;">
<tr>
<td width="174" align="right">Date:</td>
<td width="331"><input name="date" type="text" size="10" readonly/></td>
<td width="175" style="text-align:center;">Order Number:
<input name="order_num" type="text" size="10" value=""/></td>
</tr>
<tr>
<td > </td>
<td> </td>
<td style="text-align:center;"><input name="orderdetails" type="submit" value="Get Order Details" onClick="setAction('?action=getorder');"/></td>
</tr>
<tr>
<td colspan='4'> <input name="email" id="email" type="hidden" value=""/> </td>
</tr>
<tr>
<td align="right">First Name:</td>
<td><input name="fname" type="text" value=""/></td>
<td> </td>
</tr>
<tr>
<td align="right">Last Name:</td>
<td><input name="lname" type="text" value=""/></td>
<td> </td>
</tr>
<tr>
<td align="right">Image Submitted:</td>
<td><input name="image" type="text" /></td>
<td> </td>
</tr>
<tr>
<td align="right">General Comments: </td>
<td><textarea name="gen_comments" cols="50" rows="6"></textarea></td>
<td> </td>
</tr>
<tr>
<td align="right">Internal Comments:</td>
<td><textarea name="int_comments" cols="50" rows="6"></textarea></td>
<td> </td>
</tr>
<tr>
<td align="right">Quality of the File:</td>
<td colspan="2" style="padding-right:4px">
<select name="quality">
<option>Select One</option><option value="good">Good</option><option value="ok">A bit low but we can use it</option><option value="low">Low. We are concerned it might effect the qaulity of the final</option><option value="not good">Not good. We cannot work with it</option><option value="test2">test2</option><option value="test">test</option><option value="lisa">Lisa1</option><option value="bbb">aaa</option> <!--option value="good">Good</option>
<option value="ok">A bit low but we can use it</option>
<option value="low">Low. We are concerned it might effect the qaulity of the final </option>
<option value="not good">Not good. We can't work with it</option-->
</select>
现在我想做的是让所有这些输入到表单中的值存储到一个数组中,并且必须设置 cookie 以在页面重新加载时检索它们......我如何使用 javascript 和在哪里调用表单中的该函数,以便在页面重新加载时将这些值放入表单中......??我需要任何帮助..提前谢谢..