Clear all form (reset to defaults)

Modify something, press Submit and see that all modified fields are preserved!



| | | ||| | |||
||| |||

Code before and after replacement (compare!)

Original HTML code:
<form>
  <input type=text name=txt1 default="1.1" />
  <input type=text name=txt2[b] default="3.3">
  <input type=text name=txt2[] default="2.1">
  <input type=text name=txt2[] default="2.2">
  <input type=text name=txt3[a][] default="3.1">
  <input type=text name=txt3[a][] default="3.2">
  <input type=text name=txt4 default="4.1">

  <br>
  <textarea name=area1 default="ssss"></textarea>
  <textarea name=area2[]></textarea>
  <textarea name=area2[]></textarea>

  <br>
  <input type=radio name=rad1 value=r label="right"> |
  <input type=radio name=rad1 value=l label="left^"> |
  <input type=radio name=rad1 value=u> |
  <input type=radio name=rad1 value=d> |||
  <input type=radio name=rad2[a] value=u default=u> |
  <input type=radio name=rad2[a] value=d> |||

  <br>
  <input type=checkbox name=chk1[] value=aaa default>
  <input type=checkbox name=chk1[] value=bbb> |||
  <input type=checkbox name=chk2[a] value=xxx>
  <input type=checkbox name=chk2[b] value=yyy> |||

  <br>
  <select name=sel0>options[some][key]</select>
  <select name=sel1>options[other][key]</select>
  <select name=sel2 size="1">
  <optgroup label="First">
    <option value=a>aaaaaaaaaaaaa
    <option value=b>bbbbbbbbbbbbb
    </optgroup>
    <optgroup label="Second">
    <option value=c>ccccccccccccc
    </optgroup>
  </select>
  <select name=sel3[] multiple size="3" bb="eaaa">
    <option value=a>aaaaaaaaaaaaa
    <option value=b>bbbbbbbbbbbbb
    <option value=c>ccccccccccccc
  </select>
  <select name=sel4 multiple size="3">
    <option value=a>aaaaaaaaaaaaa
    <option value=b>bbbbbbbbbbbbb
    <option value=c>ccccccccccccc
  </select>

  <br>
  <input type=submit>
  <input type=submit confirm="Are you sure?">
  </form> 	
>
>
>
This HTML after processing using HTML_FormPersister:

GET data

Array
(
)

Source code

<?php include_once "../../lib/config.php"; include_once "HTML/FormPersister.php";
$ob = new HTML_FormPersister();

$options['some']['key'] = array('one' => '1111111''two' => '2222222');
$options['other']['key'] = array(
    
'Group1' => array('one'   => '1111111''two'  => '2222222'),
    
'Group2' => array('three' => '3333333''four' => '4444444'),
);

$code trim(str_replace("\t",""'
  <form>
  <input type=text name=txt1 default="1.1" />
  <input type=text name=txt2[b] default="3.3">
  <input type=text name=txt2[] default="2.1">
  <input type=text name=txt2[] default="2.2">
  <input type=text name=txt3[a][] default="3.1">
  <input type=text name=txt3[a][] default="3.2">
  <input type=text name=txt4 default="4.1">

  <br>
  <textarea name=area1 default="ssss"></textarea>
  <textarea name=area2[]></textarea>
  <textarea name=area2[]></textarea>

  <br>
  <input type=radio name=rad1 value=r label="right"> |
  <input type=radio name=rad1 value=l label="left^"> |
  <input type=radio name=rad1 value=u> |
  <input type=radio name=rad1 value=d> |||
  <input type=radio name=rad2[a] value=u default=u> |
  <input type=radio name=rad2[a] value=d> |||

  <br>
  <input type=checkbox name=chk1[] value=aaa default>
  <input type=checkbox name=chk1[] value=bbb> |||
  <input type=checkbox name=chk2[a] value=xxx>
  <input type=checkbox name=chk2[b] value=yyy> |||

  <br>
  <select name=sel0>options[some][key]</select>
  <select name=sel1>options[other][key]</select>
  <select name=sel2 size="1">
      <optgroup label="First">
        <option value=a>aaaaaaaaaaaaa
        <option value=b>bbbbbbbbbbbbb
    </optgroup>
    <optgroup label="Second">
        <option value=c>ccccccccccccc
    </optgroup>
  </select>
  <select name=sel3[] multiple size="3" bb="eaaa">
    <option value=a>aaaaaaaaaaaaa
    <option value=b>bbbbbbbbbbbbb
    <option value=c>ccccccccccccc
  </select>
  <select name=sel4 multiple size="3">
    <option value=a>aaaaaaaaaaaaa
    <option value=b>bbbbbbbbbbbbb
    <option value=c>ccccccccccccc
  </select>

  <br>
  <input type=submit>
  <input type=submit confirm="Are you sure?">
  </form>
'
));

$proc $ob->process($code);
?>

<a href=<?=$SCRIPT_NAME."?".time()?>>Clear all form (reset to defaults)</a>
<h2>Modify something, press Submit and see that all modified fields are preserved!</h2>

<?=$proc?>

<h2>Code before and after replacement (compare!)</h2>

<table width=100% height=50% cellpadding=1 cellspacing=0 border=0>
<tr>
  <td width="50%">
      <b>Original HTML code:</b>
      <pre id="left" onscroll="document.all.right.scrollTop=this.scrollTop" style="margin-top:0.3em; overflow:auto; height:auto; border:1px solid black"><font size=-1><?=preg_replace('/(default|label)/''<font color="red">$1</font>'htmlspecialchars($code))?>
     </td>
  <td valign="middle"><nobr><font size=+2><b>&gt;<br>&gt;<br>&gt;</b></td>
  <td>
      <b>This HTML after processing using HTML_FormPersister:</b>
      <pre id="right" style="margin-top:0.3em; overflow:auto; height:auto; border:1px solid black"><font size=-1><?=htmlspecialchars($proc)?>
  </td>
</tr>
</table>

<h2>GET data</h2>
<pre><?print_r($_GET)?></pre>

<h2>Source code</h2>
<?show_source($SCRIPT_FILENAME)?>