0
所以這裏是我的文檔的HTML列表:得到document's ID // PHP,JavaScript的
<form action="submitPage.html" method="post" onsubmit="submit();">
<img id="img1" src="inventory_images/berg.jpg" onclick="changeColor(this, 1);" />
<img id="img2" src="inventory_images/berg.jpg" onclick="changeColor(this, 2);" />
和JavaScript代碼,用於:
<script>
markedImage = 0; // The variable used for the submit;
function unmarkAll() {
document.getElementById("img1").style.borderColor = "#000000";
document.getElementById("img2").style.borderColor = "#000000";
}
function changeColor(obj, markedId) {
unmarkAll();
obj.style.borderColor ="#00FF00";
markedImage = markedId;
}
</script>
<script>
function submit()
{
document.getElementById("markedImage").value = markedImage;
}
</script>
因此,用戶有選擇一張圖片並點擊「提交」的可能性。 然後,他將被引導到「submitPage.html」:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
if ($_SERVER['REQUEST_METHOD'] = "POST") {
echo "Variables coming<br />";
} else {
die("No Post Variables");
}
if ($_POST['markedImage'] = "POST") {
echo "Picture has been chosen<br />";
echo "This one:<br />";
$picture_id = $_POST['markedImage'];
echo $picture_id;
} else {
echo "FAIL";
}
?>
我只是想顯示所選圖像的「身份證」。 (顯示「img1」或「img2」) 我應該改變什麼? 問候
<形式行動= 「submitPage.html」 方法= 「POST」 的onsubmit = 「提交();」>
< input type =「submit」value =「Submit」/> –
user2390560
我的js-code: – user2390560
my submitPage.html:<?php error_reporting(E_ALL); ini_set('display_errors','1'); ?> <?php $ picture_id = $ _POST ['markedImage']; echo $ picture_id; ?>現在我甚至不能用我的功能changeColor選擇一個圖像。我只想顯示所選圖像的ID,我需要更改什麼? – user2390560