2

明確にさせてください。

という名前のファイルに電子メールを送信するための HTML フォームがあります。contact.php

サーバー側では、電子メールが送信された後、これをphpで持っています

header('Location:contact.php?co=1'); exit();

クライアント側 (フォームを含む同じファイル内)

if ($_GET['co']) {
    echo 'We got it!';          
    }

したがって、ユーザーはメールが送信されたかどうかを知ることができます。

「了解しました」というメッセージをクリアするにはどうすればよいですか。

のようなものを作りたい

<input name="mail" type="email"  onFocus="cleatThemessage" ><br>

ユーザーがフォームのフィールドをクリックすると、メッセージは消えます。

ありがとう

4

4 に答える 4

1

header('Location:contact.php?co=1'); exit();

追加

$_SESSION['notification'] = "We got it";

そして変化し、

if ($_GET['co']) {
    if(isset($_SESSION['notification']) && $_SESSION['notification'] != '') {
        echo $_SESSION['notification'];
        unset($_SESSION['notification']);
    }          
}

これが機能するために、フォームがsaveContact.phpというページに送信され、データベースクエリに$_SESSION['notification'] = 'We got it'挿入した後、データベースクエリに挿入した後に1回だけ実行されるようにcontact.php?co=1にリダイレクトすると仮定しています。

于 2013-10-11T18:41:33.423 に答える
0

This could work for you:

<?php
    if ($_GET['co']) {
        echo '<div id="message">We got it!</div>';          
    }
?>

<input name="mail" type="email"  onFocus="document.getElementById('message').innerHTML = '' ;" ><br>
于 2013-10-11T18:36:37.540 に答える
0

このような:

HTML

<input name="mail" type="email"  onFocus="clearThemessage(this)" ><br>

Javascript

function clearTheMessage(element) {
   element.value = "";
}
于 2013-10-11T18:37:17.210 に答える
0
<?php
if(isset($_GET['co'])){
    echo '<p id="gotit">We got it!</p>';
}?>

<input name="mail" type="email"  onFocus="removeMessage()" >

<script type="text/javascript">
function removeMessage(){
    var el = document.getElementById('gotit');
    if(typeof(el) != 'undefined' && el != null){
        el.remove();
    }
}
</script>
于 2013-10-11T18:39:58.650 に答える