0

Hope you can help me with this. I have a html form with multiple text fields and two text areas.I use php for retrieving data from mysql database I've created a function initvars():

function initVars() {
 //declaring variables
 global $id,$ccode,$lno,$ldate,$apply_to,$type,$lexpiry,$smexpiry,$status,
     $version,$patch,$hname,$hostid,$plat,$cpus,$company,$country,$var,
$contact, $email,$po,$inv, $invdate,$notes,  $find, $reset,  $next, $previous;

$id="";
$lno = "";
$ldate="";
$apply_to="";
$type="";
$find = "";
$reset="";
$next="";
$previous="";
$apply_to="";
$lexpiry="";
$smexpiry="";
$status="";
$version="";
$patch="";
$hname="";
$hostid="";
$plat="";
$cpus="";
$company="";
$ccode = "";
$country="";
$var="";
$contact="";
$email="";
$po="";
$inv="";
$invdate="";
$notes="";
$history="";
$message ="";
$resultOffset=0;

}

Then Im calling that function under my reset button:

     if ($reset){

initVars();
  }

Ant thats a piece of html for my text area:

  <tr><td>
  <h3>History</h3>
  <textarea name="history"  cols="100" rows="5" wrap="virtual"><?php echo 
   $history;?></textarea>
   </td></tr>

And my reset button:

  <input type="submit" name="reset" value="Reset"/></td></tr></table>

For some unknown for me reason every time I hit reset button all text fields and one text area are cleared but just this "history" text area still holds retrieved data. Did anyone have similar problem or anyone know how to fix it. Any advise highly appreciated. I can paste more code if needed. Thank you all

4

2 回答 2

0
<input type="submit" name="reset" value="Reset"/>

需要改为:

<input type="reset" name="reset" value="Reset"/>
于 2013-10-24T11:16:53.507 回答
0

试试这个功能

function initVars() { //声明变量全局 $id,$ccode,$lno,$ldate,$apply_to,$type,$lexpiry,$smexpiry,$status, $version,$patch,$hname,$hostid,$平台,$cpus,$company,$country,$var,$contact,$email,$po,$inv,$invdate,$notes,$history,$find,$reset,$next,$previous;

$id=""; $lno = ""; $ldate=""; $apply_to=""; $type=""; $查找 = ""; $reset=""; $next=""; $previous=""; $apply_to=""; $lexpiry=""; $smexpiry=""; $status=""; $版本=""; $补丁=""; $hname=""; $hostid=""; $plat=""; $cpus=""; $公司=""; $ccode = ""; $国家=“”;$var=""; $联系人=""; $email=""; $po=""; $inv=""; $invdate=""; $notes=""; $历史=""; $消息=""; $resultOffset=0;

}

于 2013-10-24T11:38:02.897 回答