我想,當用戶在提交表單點擊它來改變我的「提交」按鈕樣式。PHP文件將不會顯示錶單數據
action
屬性調用PHP文件,但實際的數據不顯示,直到我從我的表單中刪除onSubmit
屬性。然後我不能使用sendBtn()
函數來改變按鈕的樣式。
僞類選項也不好,因爲它會改變風格,即使形式是空的。
任何想法?
PS。我在本地服務器上使用MAMP並使用Dreamweaver進行編輯。
<form class="customform" method="post" action="emailOnServer.php" method="post" onSubmit="return sendBtn();" autocomplete="on" >
<div class="s-12" onClick="formFocus()"><input id="imie" name="imie1" placeholder="Twoje imię" type="text" required </input></div>
<div class="s-12" onClick="formFocus()"><input id="email" name="email1" placeholder="Twój e-mail" type="email" required </input></div>
<div class="s-12" onClick="formFocus()"><textarea placeholder="Wiadomość" id="pole" rows="5" style="resize:none;" required></textarea </input></div>
<div class="custom2" style="width: 34%; float: right;" ><input id="se" type="submit" value="Wyślij" style="background-color:#92c500; color: white; border-color:#6C0;" ></input> </div>
<div class="custom1" style="width: 65%;" ><button id="resetButton" onclick="cleanBtn()" type="reset" style="background-color: #808080; color: white; border-color:#066; border-radius:2px;">Wyczyść </button></div>
<img id="tick123" src="img2/green-tick-icon-0.png" style="display: none; float:right; position:absolute; right:1%; top:86%; padding:0; margin:0; width: 28px; height: 28px;"/>
<img id="tick1234" src="img2/green-tick-icon-0.png" style="display: none; position:absolute; left:58%; top:86%; padding:0; margin:0; width: 28px; height: 28px;"/>
</form>
<!-- more code to change form style on focus -->
function sendBtn() {
\t \t
\t \t
\t \t if (document.getElementById('email').value.indexOf("@")> 0 &&
\t \t document.getElementById('email').value.indexOf(".")> 2 &&
\t \t document.getElementById('imie').value != 0 &&
\t \t document.getElementById('email').value != 0 &&
\t \t \t document.getElementById('pole').value != 0){
\t \t \t
\t \t document.getElementById('se').style.backgroundColor = "#00283A";
\t \t document.getElementById("tick123").style.display="block";
\t \t document.getElementById('se').value="Wysłano";
\t \t document.getElementById('email').disabled=true;
\t \t document.getElementById('imie').disabled=true;
\t \t document.getElementById('pole').disabled=true;
\t \t return true;}}
這是從一個免費的模板,我知道我應該使用CSS樣式表,以使其更具可讀性
這是emailOnServer.php文件:
<body>
Hello User
<?php $name = $_POST['imie1'];
\t \t echo $name; ?>
</body>
請向我們展示sendBtn()函數。確保它返回正確的值來發送表單。 –
我添加了更多的代碼,它位於''標記之間。 據我所知'真'將提交表格,它確實。然後,我在另一個選項卡中獲得.php文件,但它僅顯示「Hello User」。 – besthost
刪除標題標題 –