我有这段代码:
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);
})
我希望以下列表格发送患者身份证件。怎么做?
答案 0 :(得分:0)
请你检查一下这个
var pId = $(event.relatedTarget).data('patientId');
尝试用
替换
var pId = $(event.relatedTarget).data('patient-id');
我认为这完全取决于表单名称属性
答案 1 :(得分:0)
尝试添加id =&#34;患者ID&#34;在put标签:
<input type="hidden" value="" id="patient-id" name="patient-id" />
也
var pId = $('#patient-id').val();