0
我有這種形式可以讓您選擇背景顏色和文本顏色。提交後,我希望數據更改我的樣式表。我可以在不輸入數據庫中的值的情況下執行此操作嗎?這裏是我的形式:根據表單提交值更改樣式表
<form method="post" action="blog_settings.php">
<label for="change_background_color">Change Background Color</label>
<br>
<input type="color" name="change_background_color" id="change_background_color">
<br>
<label for="change_text_color">Change Text Color</label>
<br>
<input type="color" name="change_text_color" id="change_text_color">
<br><br>
<input type="submit" value="Submit" id="submit" onclick="return confirm('Are you sure?')">
</form>
這裏是我的崗位值:
<?php
if (isset($_POST['change_background_color'])){
$change_background_color = $_POST['change_background_color'];
}
if (isset($_POST['change_text_color'])){
$change_text_color = $_POST['change_text_color'];
}
?>
這裏是我計劃如何改變我的CSS:
body {
background-color: <?php echo $change_background_color ?>;
color: <?php echo $change_text_color ?>;
}
我知道我在這裏缺少一個步驟。我可以在沒有將顏色值輸入數據庫的情況下執行此操作嗎?
更好的嘗試jQuery提交事件 – shashi
嘗試在jQuery中做。請參閱此https://stackoverflow.com/questions/16625618/javascript-change-color-of-text-and-background-to-input-value – KMS