单击“提交”

时间:2016-08-16 14:48:11

标签: html5 forms input submit html-form

这两种方法都成功发送了数据,但刷新了表单(我试图在点击提交后通过jquery隐藏它)

#1)  <button type="submit" class="btn btn-info" value="Submit" id="submit">SUBMIT</button>

#2)  <input type="submit" class="btn btn-info" value="Submit" id="submit">

基于其他解决方案,我尝试了这两种方法。虽然他们不刷新表单,但他们也不会发送数据。

#3)  <button type="submit" class="btn btn-info" value="Submit" id="submit" onclick="return false;">SUBMIT</button>

#4)  <input type="submit" class="btn btn-info" value="Submit" id="submit">

整个代码:

<?
if (!empty($_POST)) {
    include_once 'form.php';
    $message = 'Thank You';
    }
?>
----------- 
<script>
    $(document).ready(function() {
        $('input[type="radio"]').click(function() {
            if($(this).attr('id') == 'other_radio') {
                $('#other').show();
            } else {
                $('#other').hide();
            }
        });
    });
</script>

-----------
<div class ="form-hide">
<form method="post" role="form" id="survey">
    <div class="form-group">
        <label>How did you hear about us?</label>
        <div class="radio">
            <label><input type="radio" name="howdidyouhearaboutus" value="Facebook">Facebook</label>
        </div>
        <div class="radio">
            <label><input type="radio" name="howdidyouhearaboutus" value="Online Ad">Online Ad</label>
        </div>
        <div class="radio">
            <label><input type="radio" name="howdidyouhearaboutus" value="TripAdvisor">TripAdvisor</label>
        </div>

    </div>

    <div class="form-group">
        <input type="submit" class="btn btn-info" value="Submit" id="submit" onclick="return false;">
</div>
</form>

    <? if ($message): ?>
    <div class="text-center alert alert-success">
        <?= $message ?>
    </div>

<? endif; ?>

</div>
--------------------
<script>
 $('#submit').click(function(){
   $('.form-hide').hide();
 });
</script>

form.php适用于Google表格API集成,不确定我是否需要在此处添加?     

$client = new Google_Client();
try {
    $client->setAuthConfig('account.json');
} catch(Exception $ex) {
    exit('account.json not found.');
}
$client->setScopes(['https://www.googleapis.com/auth/drive','https:    //spreadsheets.google.com/feeds']); ........

0 个答案:

没有答案