簡體   English   中英

如何解決這個錯誤? 未定義

[英]How to fix this error? Undefined

我有以下代碼:

HTML:

<form method="post" action="<?php  echo $this->serverUrl().str_replace('public','',$this->basePath()).'/user/sendmessagetoinbox/'; ?>">
    <fieldset>
        <label>Subject</label>
        <input type="text" name="inbox_subject" />
    </fieldset>
    <fieldset>
        <label>Message</label>
        <textarea name="inbox_message"></textarea>
    </fieldset>
    <fieldset>
        <button type="submit" class="btn btn-primary btn-save send-btn">Send message to inbox</button>
        <!-- <input type="submit" class="btn btn-submit" value="Send message to inbox" /> -->
    </fieldset>
    <input type="hidden" value="" name="patient-id" />
</form>

JS:

$('#inMail').on('show.bs.modal', function (event) {
    var url='<?php  echo $this->serverUrl().str_replace('public','',$this->basePath()).'/user/sendmessagetoinbox/'; ?>';
    console.log(url);
    var pId = $(event.relatedTarget).data('patientId')
    console.log(pId);   //UNDEFINED
    $(".modal-body").find('form').attr("action",url+pId);
})

我希望通過以下表格發送患者ID。 這個怎么做?

你能檢查一下嗎
var pId = $(event.relatedTarget).data('patientId');
嘗試替換為
var pId = $(event.relatedTarget).data('patient-id');

我認為這全都與表單名稱屬性有關

嘗試在put標簽中添加id =“ patient-id”:

<input type="hidden" value="" id="patient-id" name="patient-id" />

var pId = $('#patient-id').val();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM