第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將提交表單值從模態(tài)發(fā)送到另一個模態(tài) php

將提交表單值從模態(tài)發(fā)送到另一個模態(tài) php

尚方寶劍之說 2023-09-21 16:54:54
我正在一個 php 項目中工作,我有兩個模式。第一個模態(tài)包含一個表單,提交表單后,該模態(tài)必須使用 $_POST 將表單值發(fā)送到另一個模態(tài)(將在提交后出現(xiàn))。除了 $_POST 數(shù)組在第二個模式中顯示為空之外,所有這些步驟都有效。我想知道是否缺少一些我必須包含的東西,或者我應(yīng)該使用其他 jQuery 的東西。這是我的代碼<button type="button" class="btn btn-red pull-right" data-toggle="modal" data-target="#newvisitor1" data-whatever="@mdo">New Visitor</button><!-- First Modal --><div class="modal fade" id="newvisitor1" tabindex="-1" role="dialog" aria-labelledby="modelLabel" aria-hidden="true" data-backdrop="static">    <div class="modal-dialog" role="document">        <div class="modal-content">            <div class="modal-header">                <h5 class="modal-title" id="modelLabel">New Visitor</h5>                <button type="button" class="close" data-dismiss="modal" aria-label="Close">                    <span aria-hidden="true">&times;</span>                </button>            </div>            <form id="visitorForm1" action="" method="post" role="form">                <div class="modal-body">                    <div class="form-group mb-4">                        <input type="text" class="form-control" id="cpr" name="cpr" pattern="\d*" title="only numbers allowed" minlength="9" size="9" maxlength="9" placeholder="Visitor CPR" required>                    </div>                </div>                <div class="modal-footer">                    <button type="button" id="cancel1" class="btn btn-secondary" data-dismiss="modal">Cancel</button>                    <button type="submit" id="checkVisitor" name="checkVisitor" class="btn btn-red pull-right">Check Visitor</button>                </div>            </form>        </div>    </div></div>
查看完整描述

1 回答

?
ABOUTYOU

TA貢獻1812條經(jīng)驗 獲得超5個贊

第一種形式不需要發(fā)送數(shù)據(jù)。您可以從第一個表單中提取值,并在提交第一個表單時將其設(shè)置在第二個表單中。


不過,由于兩個模式都在同一頁面上,因此您需要修改第二個cpr字段的 id。否則你的 id 就會重疊,這會讓它們變得毫無用處。


在下面的示例中,我cpr在第二個 modal 中命名了該字段cpr2。請隨意以其他方式命名。


$(document).ready(function () {

  $("#visitorForm1").submit(function(event) {

    event.preventDefault();


    // Get CPR value of first modal.

    const cprValue = $('#cpr').val();


    // Set the CPR value in the second modal.

    $('#cpr2').val(cprValue);


    $('#newvisitor1').modal('hide');

    $('#cancel1').click();

    $('#newvisitor2').modal('show');

    return false;

  });

});


查看完整回答
反對 回復(fù) 2023-09-21
  • 1 回答
  • 0 關(guān)注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號