当前,我能够从下拉框中选择一个选项,这为我提供了另一组选项供您选择。然后,我可以选择“添加”,它查询数据库并发送回响应。我对其进行了更改,因此所有信息都显示在列表中,而不是下拉列表中,但是当我尝试选择“添加”时,它将加载,然后不发送查询/不接收任何内容。两者都使用相同的方法,为什么它不通过新方法将任何内容发送到数据库?我还需要能够选择其他选项,例如性别-男性/女性,已订阅的是/否,并且如果选择了该查询,则会在查询中搜索每个不同的查询。
要发送的当前代码
脚本(两者相同)
window.onunload = refreshParent;
function refreshParent() {
window.opener.location.reload();
}
$body = $("body");
$(document).on({
ajaxStart: function() { $body.addClass("loading"); },
ajaxStop: function() { $body.removeClass("loading"); }
});
$(document).ready(function() {
// Variable to hold request
var request;
$(".chosen-select").chosen({width: '300px'});
//$("#distance_slider").slider({});
// Bind to the submit event of our form
$("#criteria").submit(function(event){
// Prevent default posting of form - put here to work in case of errors
event.preventDefault();
// Abort any pending request
if (request) {
request.abort();
}
// setup some local variables
var $form = $(this);
//$("#isajax").val("1");
// Let's select and cache all the fields
var $inputs = $form.find("input, select, button, textarea");
// Serialize the data in the form
var serializedData = $form.serialize();
// Let's disable the inputs for the duration of the Ajax request.
// Note: we disable elements AFTER the form data has been serialized.
// Disabled form elements will not be serialized.
$inputs.prop("disabled", true);
// Fire off the request to /form.php
request = $.ajax({
url: "index.php?module=Prospects&action=PopupContactsCriteria&html=Popup_Contacts_Criteria_picker&form=ContactsForm&record={RECORD_VALUE}&first_run=1&form_submit=true&query=true&sugar_body_only=1",
type: "post",
data: serializedData
});
// Callback handler that will be called on success
request.done(function (response, textStatus, jqXHR){
// Log a message to the console
//console.log("Hooray, it worked!");
//console.log(response);
document.open();
document.write(response);
document.close();
});
// Callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown){
// Log the error to the console
console.error(
"The following error occurred: "+
textStatus, errorThrown
);
});
// Callback handler that will be called regardless
// if the request failed or succeeded
request.always(function () {
// Reenable the inputs
$inputs.prop("disabled", false);
});
});
当前代码以选择选项示例
<form id="criteria" name="criteria">
<table width="100%" border="0">
<tr>
<td>
<table width="100%" name="criteria_search">
<tr>
<td class="dataLabel" width="75%" align="left"><strong>Add Rule : </strong>
<select name="rule" id="rule" onChange="toggletdDisplay(this.form);">
<option value="email">Email</option>
</select>
</td>
<td align="right" name="buttonForm" id="buttonForm">
<input type="hidden" name="action" value="PopupContactsCriteria"/>
<input type="hidden" name="query" value="true"/>
<input type="hidden" name="record" value="{RECORD_VALUE}"/>
<input type="hidden" name="module" value="{MODULE_NAME}" />
<input type="hidden" name="form_submit" value="{FORM_SUBMIT}" />
<input type="hidden" name="sugar_body_only" value="1" />
<input type="hidden" name="form" value="{FORM}" />
<input class="button" type="submit" name="addButton" id="addButton" value=" Add Selected " disabled/>
</td>
<td class="dataLabel" name="instructions" id="instructions" style="display: inline;padding: 50px;"> <p style="color:black;font-size:10px;"><br /> <i> </i> </td>
<tr>
<td class="dataLabel" name="email" id="email" >Email Address Required? Yes <input type="radio" name="email_c" value="true_ex" {EMAIL_TEX_CHECKED}> No <input type="radio" name="email_c" value="false" {EMAIL_F_CHECKED}></td>
</tr>
(一切都关闭了,这只是一个例子,效果很好)
这就是我现在想要做的-系统加载然后什么也不做。 (从下拉列表开始,由于有很多选项,我是否缺少一些用于查询数据库的数据,因此简化为一个)
<button onclick="myFunction()">Show Additional Rules (*Not Required)</button>
<div id="myDIV" hidden="true">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="edit view">
<tr>
<td>
<form id="additional_criteria" name="additional_criteria">
<table width="100%" border="0" name="additional_criteria">
<tr>
<td><p><Strong> Additional Rules</strong><p/></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td class="dataLabel" name="email" id="email" >Email Address Required? Yes <input type="radio" name="email_c" value="true_ex" {EMAIL_TEX_CHECKED}> No <input type="radio" name="email_c" value="false" {EMAIL_F_CHECKED}></td>
</tr>
<tr>
<td align="right" name="buttonForm" id="buttonForm">
<input type="hidden" name="action" value="PopupContactsCriteria"/>
<input type="hidden" name="query" value="true"/>
<input type="hidden" name="record" value="{RECORD_VALUE}"/>
<input type="hidden" name="module" value="{MODULE_NAME}" />
<input type="hidden" name="form_submit" value="{FORM_SUBMIT}" />
<input type="hidden" name="sugar_body_only" value="1" />
<input type="hidden" name="form" value="{FORM}" />
<input class="button" type="submit" name="addAdditionalButton" id="addAdditionalButton" value=" Add Additional " />
</td>
</tr>
</table>
</form>
</td>
</td>
</table>
</div>