javascripで取得idをphpでpostでそうしたいのですか誰か教えていただきませんか?
補足:
index.phpの<div id="param" name="param"></div>これのid="param"はjavascriptfで取ってきました。
name="param"はformのアクションのPOSTでconfirm.phpに渡していますがこれが渡されてないです
12.htmlの12をindex.phpファイルに取得し、さらに、index.phpファイルから <form action="confirm.php" method="post" >で送って、confirm.phpで表示したいのですがなかなかできません、
index.phpまでは取得できていますが、confirm.phpの中には取得できていません、
javascript.js
window.onload = function onLoad() { param = GetQueryString(); target = document.getElementById("param"); target.innerHTML = param["q"]; } function GetQueryString() { if (1 < document.location.search.length) { var query = document.location.search.substring(1); var parameters = query.split('&'); var result = new Object(); for (var i = 0; i < parameters.length; i++) { var element = parameters[i].split('='); var paramName = decodeURIComponent(element[0]); var paramValue = decodeURIComponent(element[1]); result[paramName] = decodeURIComponent(paramValue); } return result; } return null; }
index.php
こちらは12.htmlの12を表示させています。
<form action="confirm.php" method="post" onsubmit="return validate()" enctype="multipart/form-data"> <div><span>ID</span></div> <div id="param" name="param"></div> <button type="submit">確認画面へ</button> </form>
下記はconfirm.phpにnameのparamのid値を取得したいです
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $param = $_POST["param"]; ?> <form action="confirm.php" method="post"> <input type="hidden" name="param" value="<?php echo $param; ?>"> <div><span>ID</span></div> <p><?php echo $param; ?></p> <button class="submit-confirm" type="submit" name="submit">送信する</button> </form>
回答3件
あなたの回答
tips
プレビュー