以下に、PHPフォームの変数をjavascriptのオブジェクトのリストに保存する関数があります
a.js
function save()
{
var oldItems = JSON.parse(localStorage.getItem('itemsArray')) || [];
var newItem =
{
'num' : document.getElementById("num").value,
'methv' : document.getElementById("methv").value,
'q1' : document.getElementById("q1").value,
'q2' : document.getElementById("q2").value,
'q3' : document.getElementById("q3").value,
'q4' : document.getElementById("q4").value,
'comm' : document.getElementById("comm").value
};
oldItems.push(newItem);
localStorage.setItem('itemsArray', JSON.stringify(oldItems));
}
php ページにコンテンツを表示して編集できるようにするにはどうすればよいですか? (印刷されたものの例は大歓迎です)
編集*
これらは、オブジェクトに追加される値です
<form action="" method="post" enctype="multipart/form-data">
<select name="methv" class="textfields" id="methv" style="width:110px" >
<option value= "dont know">dont know </option>
<select name="q1" class="textfields" id="q1" style="width:50px" >
<option value= "-">-</option>
<option value= "L">L</option>
<select name="q2" class="textfields" id="q2" style="width:50px" >
<option value= "-">-</option>
<option value= "L">L</option>
<select name="q3" class="textfields" id="q3" style="width:50px" >
<option value= "-">-</option>
<option value= "L">L</option>
<select name="q4" class="textfields" id="q4" style="width:50px" >
<option value= "-">-</option>
<option value= "L">L</option>
<textarea rows="4" cols="40" id="comm" name="comm" style="width:300px"><?php echo $post['addcomment'] ;?></textarea>
</form>
私は a.js だけをインポートしました<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>